test += 1 + 1;
Integer.MAX_VALUE + 1;
String[] s = new String[3];
System.out.println(s[0].toString());
int result = 12 / 0; //ArithmeticException
// anything else will not throw an error, but have varying results such as NaN & Infinity
Can't declare static var in main
public static void main(String args[]) {
static double f = 3; //error
}
- Private Constructors
- Enums
- getInstance()
- Should be thread safe
- Inner Class without a name
- Single object is created
- Can be created from an interface
- Can have variables
- Check class access modifier table
- Cannot assign weaker access privileges
- For this one, both protected and public works fine if have same method signature
class Test {
double test(double x) {
return x;
}
}
class Testes extends Test {
//will have compilation error, unless you change access modifier to public or protected
@Override
private double test(double x) {
x *= 10;
return x;
}
}
The only value we can assign to a Void variable is null. Hence, this is allowed
void useMe() {
return null;
}
However, useMe()
** does not return a value**
- TextArea:
- Multiple lines
- Not resizable
- Not scrollable
- Textfield
- Single line
// this is an anonymous class
button.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent e) {
label.setText("Accepted");
}
});
String s = "abc";
if (s == "abc") {
System.out.println("== works"); //bad practise but works
}
if (s.equals("abc")) {
System.out.println("method works");
}
stage.setScene(scene2);
stage.setHeight(1000);
stage.setWidth(1000);
The API for Integer.valueOf(String) does indeed say that the String is interpreted exactly as if it were given to Integer.parseInt(String). However, valueOf(String) returns a new Integer() object whereas parseInt(String) returns a primitive int.
Primitive type Wrapper class
boolean Boolean
byte Byte
char Character
float Float
int Integer
long Long
short Short
double Double