You are on page 1of 1
22-3 The SIZE constants: “The wrapper classes Double, Float, Long, Integer, Short, Character, and Byte all employ the constant SIZE This reports how many bits comprise the primitive types that these classes represent. The values are obtained by multiplying the number of bytes for each type in Appendix C by § bits in each byte. Their values are Double SIZE = 64 Float SIZE = 32 Long SIZE = 64 Integer SIZE Short SIZE = 16 Character SIZE = 16 Byte SIZE= Boolean does not have a SIZE constant Exercise on Lesson 22 1, Write code that will convert a String called rr into an int type called i 2. The Strings contains “123.456”. How would you convert this into a double type variable? 3. What evidence is there in the following statement that the method is static? int v= Integer parseint(s); 4, How would you convert decimal equivalent String sd to String sh in hex form? 5. Suppose you have an int type stored in jj. How would you convert this into a String? 6. Suppose you must pass the Jnteger object equivalent of 1000 as a parameter to a methodA, however, all you have is a String representation ss of that integer. Show how. you would manipulate ss and change it into an object called obj so that it could be used as a parameter for methodA 7. Whatiis output by the following code? String pdq="-772.29", System out println( 3 + Double parseDouble(pdq) ), 8. Assume /Obyis an Integer object “wrapping” the value -186. What is output by the following code? int ip =i0bj; //Pre java 5.0, int ip = i0bj intValue( ), String mz ="3" + Integer toString(ip) + "3", System out println(mz), 9. Write code that will convert “3pih” (a String representation of a base 33 number) to inti 10. Write code that will convert int i into its String equivalent in base 6

You might also like