Sie sind auf Seite 1von 2

Java Notes System.out.println(HI) Variables: floats must be casted float f = (float) 4.

5 if statements must take a bool, not an int String String String String is s1 s2 se capitalized and is not a primitive = new String(HI); = HI; = s1 + s2

Conditionals: == works on objects so cannot be used to compare strings a.equals(b) works to compare two strings Arrays int[] arr arr = new int[10] arr.length int[] arr = {1,2,3,4,5} Loops: int[] arr = {2,0,1,3}; for(int el : arr) { System.out.println(el); } functions: static function belongs to class, not specific instance non static methods belong to object primitives passed by value, objects passed by reference classes Point p = new Point(); constructor same as c++ Point(int x, int y){ this.x = x; this.y = y; } can define multiple constructors like c++ Point() { this(0,0);} // calls other constructor this is a reference to the object currently being used compiling & running with arguments java or java.exe javac or javac.exe javac MyFirstClass.java << compiles your project >>creates class object called MyFirstClass.class to run call: java myFirstClass public static void main(String[] args) -this will hold all commandline arguments inheritance: class Shape {} class Circle extends Shape {}

extends is used to make a derived class can be passed into function as shape as long as both class has necessary functions to be used Try and Catch try { } catch (ExceptionHere name) { do stuff }

An Intent is an object that provides runtime binding between separate components (such as two activities). The Intent represents an app's "intent to do something. " You can use intents for a wide variety of tasks, but most often they're used to start another activity.

Das könnte Ihnen auch gefallen