I’m until now don’t know what is the actual use of private and final.
I think final is like const in C/C++. And private maybe like static.
This works fine for final and can’t be changed:
void print_static(){
final int a = 100;
println(a);
}
When I change it to private I get this error:
void print_static(){
private int a;
println(a);
}
Error:
Illegal modifier for parameter a; only final is permitted
So I guess I have to use a class to be able to use private. But I’m having some problems calling functions from a class. I don’t know what I’m missing here. I tried this:
public class class_example {
public void print_hi() {
println("Hi there!");
}
}
But output window freezes and I get error this error:
NullPointerException