what method can be used to create a new instance of an object code example

Example 1: create instance object java

myCar = new Car();

Example 2: make an object in java

public class Puppy {
   public Puppy(String name) {
      // This constructor has one parameter, name.
      System.out.println("Passed Name is :" + name );
   }

   public static void main(String []args) {
      // Following statement would create an object myPuppy
      Puppy myPuppy = new Puppy( "tommy" );
   }
}

Example 3: how to make new paruser object

ParseUser parseuser = new ParseUser(); // It's just a simple class object

Tags:

Java Example