1.Error: Accessing Instance Global Variable in Static Method
class GlobalError1 { int cost = 1000 ; // instance global variable
public static void main ( String args []) { System . out . println ( cost ); // ERROR } }
Enter fullscreen mode
Exit fullscreen mode
Output
non-static variable cost cannot be referenced from a static context
class GlobalError1 { int cost = 1000 ;
public static void main ( String args []) { GlobalError1 obj = new GlobalError1 (); System . out . println ( obj . cost ); } }
Enter fullscreen mode
Exit fullscreen mode
2.Error: Using Object for Static Variable
class GlobalError2 { static String name = "Scooby" ;
public static void main ( String args []) { System . out . println ( namee ); // spelling error } }
Enter fullscreen mode
Exit fullscreen mode
Output
Cannot find symbol
class GlobalError2 { static String name = "Scooby" ;
public static void main ( String args []) { System . out .…