import java.util.Scanner;
public class Person
{
String name,address,job;
byte age;
Person(){}
Person(String name,byte age,String address,String job)
{
this.name=name;
this.age=age;
this.address=address;
this.job=job;
}
void Display()
{
System.out.println("name = "+name);
System.out.println("age = "+age);
System.out.println("address= "+address);
System.out.println("job = "+job);
}
void setAddress(String address)
{
String add=address;
}
String getAddress(String address)
{
return address;
}
public static void main(String[] args)
{
Scanner input=new Scanner (System.in);
Person p = new Person();
System.out.print("name is ");
String s=input.next();
System.out.print("age is ");
byte x=input.nextByte();
System.out.print("address is ");
String y=input.next();
System.out.print("job is ");
String z=input.next();
Person P = new Person(s,x,y,z);
P.Display();
}
}
Its Very simple Well if u define any type of Constructor with arguments in a class then u have to define also a default Constructor with no arguments .java not provide a default Constructor in this your case .Java Can provide default Constructor when no Constructor in the class.