Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
6 views

Java Quick Sheet

1. This summarizes the key concepts in object-oriented programming and Java based on the provided document. 2. It includes data types like int, string, boolean, and object types; variable scopes like public, private, protected; classes and objects; and control structures like if/else, for loops, and methods. 3. Key concepts are explained concisely like public/private access modifiers, importing packages, object instantiation with new, parameter passing in methods, and primitive vs. reference types.

Uploaded by

Raja Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Java Quick Sheet

1. This summarizes the key concepts in object-oriented programming and Java based on the provided document. 2. It includes data types like int, string, boolean, and object types; variable scopes like public, private, protected; classes and objects; and control structures like if/else, for loops, and methods. 3. Key concepts are explained concisely like public/private access modifiers, importing packages, object instantiation with new, parameter passing in methods, and primitive vs. reference types.

Uploaded by

Raja Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1. // [comment] 10.

Private 64-bit number with


decimals.
Single line comment. Can only be changed by a
method.

19. float
2. /* [comment] */
11. int 32-bit number with
Multi line comment.
decimals.
Can store numbers from
2^31 to 2^31.
3. public
20. protected
This can be imported
12. fields are attributes Can only be accessed by
publically.
other code in the package.

13. boolean
4. import [object].*
21. Scanner
Can have true or false as the
Imports everything in
value. This lets you get user input.
object.

14. { } 22. new [object constructor]


5. static
These are used to start and This will let you create a
Going to be shared by every
end a function, class, etc. new object.
[object].

15. byte 23. System.in


6. final
These can store from -127 - This lets you get data from
Cannot be changed;
128. the keyboard.
common to be defined with
all uppercase.

16. long 24. public [class]()

7. double Can store numbers from This will be the constructor,


2^127 to 2^-127. you use it to create new
Integer with numbers that
objects.
can have decimals.

17. char
25. super()
8. ; Just lets you put in one
chracter. This will create the
Put after every command.
superclass (the class it's
inheriting).
18. double
9. String
26. extends [class]
Just a string of characters.
Makes the object a subclass 35. public static void 44. <
of [object], [object] must be main(String[] args)
This means less than.
a superclass.
This is your main function
and your project will start in
here. 45. >
27. ++
This means greater than.
Will increment the amount.
36. System.out.print([text])

This prints stuff but there is 46. >=


28. --
no line break. (/n)
This means greater than or
Will decrement the amount.
equal to.
37. \n
29. += [amount]
Called a line break; will print 47.
Increment by [amount] a new line. [inputVarHere].hasNextLine
()

This will return if there is a


30. -= [amount] 38. \t
next line in the input.
Decrement by [amount] This will print a tab.

48. this
31. *= [amount] 39. if ([condition])
Refer to the class that you
Multiply by [amount] This will make it so if are in.
[condition] is true then it'll
keep going.
32. /= [amount] 49. [caller].next[datatype]()

Divide by [amount] This will get the [datatype]


40. &&
that you somehow inputted.
This means and.
33.
System.out.println([text]) 50. Create getters and
41. ! setters
Will print something to the
output console. This means not. This will create the get
methods and set methods
for every checked variable.
34. + 42. ||

Can be used for This means or.


51.
concatenation. (ex. "6" + [caller].hasNext[datatype]()
[var_here]) This will return if it has the
43. == correct datatype within the
This means equal to. input.
59. ^ This will start at [number]
and then do [operation]
52. overloading Return true if there is one
until [condition] is met.
true and one false.
If you have different
parameters you can call
them whatever way you 67. continue
60. !=
want.
This will just go back to the
Not equal too. (NEQ)
enclosing loop before
reaching other code.
53. parameters
61. ([condition]) ? [amount]
These are the inputs of your
: [var]
function. 68. while ([condition])
This will be like a shortcut
This will basically do
way to an if statement.
something while [condition]
54. ([datatype])[variable]
is true.
This will convert [variable]
62. switch([variable])
into [datatype]. Also known
as casting. This will do stuff with 69. void
specific cases. (e.g.
This means no return type.
switch(hi){ case 2: (do
55. Math.random() stuff)})

Generate an extremely 70. return


percise string of numbers
63. case [value]: This will return something
between 0 and 1.
when you call it to where it
This will do stuff if the case
was called from .
is the case.
56. Primitives

Just the basic data types 71. do { } while ([condition])


64. break
which are not objects.
Guarantees it will execute
Put that when you want to
once even if [condition] isn't
leave the loop/switch;
met.
57. [x].toString() should be at end of case.

Will convert [x] into a string.


72. printf("%[type] stuff
65. default [value]:
here bah bla", [variable
58. This will do stuff if none of here])
[number].parse[numbertyp the cases in the switch
This will let you use
e]([string]) statement was made.
[variable here] with %s
This will parse [number] into 66. for ([number]; being where.
the [numbertype] with [condition]; [operation])
[string].
73. System.out.printf([text])
Another way to print? // This will get how long
didn't quite get but ok then something is, text, amount
of indexes in array, etc.

74. [type] [returntype]


[name]([parameters]) { 80. Arrays.copy0f([array],
indexes);
This is a way to create a
method. This will copy the array and
how many indexes into
another array.
75. [type][[indexes]]

This will create an array with


81. Arrays.toString([array])
[indexes] amount of
indexes; default infinite. Convert the whole array into
one huge string.

76. int[] something = new


int[20]; 82.
Arrays.binarySearch([array],
This will just make an array
[object])
of ints with 20 ints in it.
This will search for [object]
in [array].
77. for ([object]
[nameOfObject] :
[arrayOfObject]) {

This will iterate through all


of the arrayOfObject with
object in use incrementing
by 1 until done.

78. [object][[1]][[2]][[3]]
[name] = {[value] [value]
[value] \n [value] [value]
[value]}

[1] is how many down in


array, [2] how many accross
in array, [3] how many
groups

79. .length

You might also like