-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjava_notes.txt
More file actions
42 lines (31 loc) · 954 Bytes
/
java_notes.txt
File metadata and controls
42 lines (31 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Only including differences from C++
BASICS
Everything must be in a class
Class contains main function
I/O
System.out.println("Tyler")
Classes
class MyClass {
public myClass() { //Constructor
}
public static void main(String[] args) {
myClass instance = new myClass();
}
int myInt //Data member (instance variable)
}
class MyChild extends MyClass {} //Inheritance
Data Structures
import java.util.ArrayList
ArrayList<Integer> myList = new ArrayList<Integer>() //Must use wrapped type, Integer instead of int
myList.add(value)
myList.get(index)
myList.add(index, value)
myList.size()
HashMap<String, Integer> myFriends = new HashMap<String, Integer>()
myFriends.put("Mark", 24)
myFriends.get("Mark") //Returns value associated with the specified key
myFriends.keySet() //Returns a list of the keys
Loops
for (Integer grade : quizGrades) //For each element in quizGrades, represented by grade
static
public