ex14 - Primitive types vs Reference types primitive type...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Primitive types vs Reference types primitive type reference type Cheater class (i.e. int) (class, i.e. Scanner) String class declaration int i; Scanner s; String s; Allocation s = new Scanner(. .); initialization i = 0; new Scanner(System.in); s = "hello"; operations i += 5; s.nextDouble(); s = s + "howdy"; comparisons i == 5 s.equals(s2); s.equals("hi"); i < 5 ??? s.compareTo("hi"); How do we find information on what methods are in a class? JavaDocs, which are online. http://java.sun.com/j2se/1.5.0/docs/api/overview-summary.html If you go to google and type: string javadocs - you will get the documentation for the String class. scanner java.util - you will get the documentation for the Scanner class. This will be very useful in your programming of Java, because no textbook contains all of the methods you might want to use. public class Counter { // instance variable - a copy in each object private int myCounter; // class variable (one per class, shared among objects) private static int globalCounter = 0;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/27/2011 for the course CMPSC 5 taught by Professor Franklin during the Fall '09 term at UCSB.

Page1 / 2

ex14 - Primitive types vs Reference types primitive type...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online