spot the difference between below codes, which one is good and why
code # 1
public class StaticExample {
/**
* @param args
*/
public static final String name;
static{
String nam = "sai";
name =nam;
}
public static void main(String[] args) {
System.out.println(name);
}
}
code # 1
public class StaticExample {
/**
* @param args
*/
public static final String name;
static{
String nam = "sai";
name =nam;
}
public static void main(String[] args) {
System.out.println(name);
}
}
Code # 2
public class StaticExample {
/**
* @param args
*/
public static final String name;
static{
name ="sai";
}
public static void main(String[] args) {
System.out.println(name);
}
}
No comments:
Post a Comment