w = dogContainer.getWidth();
dogContainer.add(eyes((int)(.37*w, .39*w*1.75, w/4), eyeColor), 0);
I am getting an error trying to cast an Int to all these parameters, how do I correctly do it?
Please post the compile time error so it is easier for people to help you.
You do not need to cast an int
to a long
(notice use of lower case data types) - this will be take care-off by an underlying technique called conversion.
However if you are using Integer
and Long
(Upper case and full words) - these are wrapper class and the conversion will NOT happen automatically. You will need to do something like
Long myLong = myInteger.longValue();
Also as an additional observation (since the code is not posted I cannot be certain) - you are multiplying with a double 1.75
- if you perform operations that include a double the result will be a double even if some of the operands (like say w
) is an int or a long (again something managed under the hod by conversion.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.