create objects in java code example
Example 1: java create new object
Car mycar = new Car();
Example 2: create instance object java
myCar = new Car();
Example 3: 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 4: how to make a class in java
public class Main {
public static void main (String[] args) {
System.out.println("Hello World");
}
}