Presentation is loading. Please wait.

Presentation is loading. Please wait.

Java Basics.  To checkout, use: svn co scb07f12/UTORid  Before starting coding always use: svn update.

Similar presentations


Presentation on theme: "Java Basics.  To checkout, use: svn co scb07f12/UTORid  Before starting coding always use: svn update."— Presentation transcript:

1 Java Basics

2  To checkout, use: svn co svn+ssh://(UTORid)@mathlab.utsc.utoronto.ca/svn/c scb07f12/UTORid  Before starting coding always use: svn update  After finished some part of code, use: svn commit  If added a file use: svn add

3  Primitive data types: int, boolean, double, long, char -Variable assignment creates a new variable! (new memory location)  Objects: String, ArrayList, Integer -Variable assignment passes a reference to the same object! (same memory location - use ‘new’ to create a new modified object)

4  For Objects, use:.equals() (== will check the address in memory)  For Primitive Types, use: ==

5  String a = "Joshua"; Strings are immutable! a+a is still a!  StringBuilder c = new StringBuilder("Baby"); String builder is like a mutable String  Arrays: int[][] table = new int[50][30] Can’t change the size once created! (recreate)  ArrayList: ArrayList names = new ArrayList (); Size changes as needed + lots of functions!

6  int num = 5 while (num > 0) { num --; }  for (int i = 0; i < 10; i++) { }  String word = ”icantcomeupwithone” for (char letter : word){ System.out.println(letter); }

7  Wrapper is an Object class for a primitive type Eg: Integer, Double, … They provide extra functions like conversion: Integer.parseInt(“56”);  Casting is explicit conversion to some Object Object obj = “StringularThing”; String str = (String) obj; Help avoid compiler errors but may cause runtime. Careful!

8  Scope is method’s or variable’s visibility  Passing variables to functions: For primitive data types new variable is created in the function’s scope For Objects – a reference to the same Object is passed along to the function’s scope  Refer to Variables and Pointers slide!


Download ppt "Java Basics.  To checkout, use: svn co scb07f12/UTORid  Before starting coding always use: svn update."

Similar presentations


Ads by Google