Instantiate an object named “myObj” and output the value of x.
public class Main { int x = 5;
public static void main(String[] args) { Main myObj = new Main(); System.out.println(myObj.x); } } |
The “new” keyword instantiates new objects.