CSC152 2005S, Class 9: Numeric Values in Java Admin: * Reading: How to build your own classes (ready later this afternoon, I hope) * Instructions on submitting labs to be released soon (I hope) * Today's lab is a little bit more basic, but I think it needs to be. Overview: * Wrapup on strings * Primitive types vs. classes * Other Questions on numbers? * Lab * Reflection Interesting Java design: N ways to represent most numeric values * Are numbers objects or something else? * Numbers can be represented in their base/primitive form byte,short,int,long: integers with different possible "sizes" float,double: approximations of real numbers * Numbers can also be represented as objects Byte,Short,Integer,Long Float,Double * "Arbitrary precision" java.math.BigInteger java.math.BigDecimal Other questions on the reading? * What's 1/3? * You'll find out on the lab Tips, Questions, and Such * To refer to a method, we use either ObjectName.methodName or ClassName.methodName * To refer to a field (particularly a constant field), we use either ObjectName.fieldName or ClassName.fieldName * E.g. java.lang.Integer.MAX_VALUE Why is it that java.lang.Integer.MAX_VALUE != -1*java.lang.Integer.MIN_VALUE Some of you have discovered import java.io.* as a shorthand for import java.io.File; import java.io.FileReader; ... YOU MAY NOT DO SO Why? Suppose some writes import rebelsky.class1.*; import java.io.*; import schmitzc.coolstuff.*; ... SillyThing st = new SillyThing(); So ... it's mostly to make it easier for the reader. When you are advanced programmers, it's okay.