a few beginners questions ....
Hello, I am new to the java envoierment. I have several questions regarding
this language:
1. How about using class initializer ? When it is run ? If i include a class
from package, will it be also an initializer run for every class in that
package ?
2. I have problem with this code :
// FILE primer.java
import static narzedzia.LiczbyPierwsze ;
public class primer {
public static void main(String[] args) {
LiczbyPierwsze.main();
// TODO, add your application code
System.out.println("Hello World!");
}
}
// FILE LiczbyPierwsze
package narzedzia;
public class LiczbyPierwsze {
protected final static long length = 21;
protected final static long sito [] = new long [1<<length];
public static void main(String[] args){
int i;
for (i=0;i<length;i++){
System.out.println(sito[i] + "\n ");
}
}
public final static long czyPierwsza(long x ){
return 0;
}
public final static long naCzynnikiPierwsze(long x){
return 0;
}
}
//
When compiling this I've got: " cannot find symbol main".
3. Is the static public main() method a class initializer ? If so, suppose
we have code like that :
class Dummy{
static int i=3;
public static main(){
i=7;
}
public static get_i{
System.out.println(i);
}
}
and than if someone call Dummy.get(i) out of that class what would be the
output of the program. Yes i know i can run it myself, but could someone
explain me the result ? Is the line
static int i=3; regerded as a part of initializer ?