import java.util.Scanner;
class orange
{
private String girlName;
public orange()
{
girlName="not known.";
}
public orange(String name)
{
girlName=name;
}
public void setName(String name)
{
girlName=name;
}
public String getName()
{
return girlName;
}
public void message()
{
System.out.println("Your 1st gf name is "+getName());
}
}
class apples
{
public static void main(String args[])
{
Scanner harry=new Scanner(System.in);
String name;
System.out.print("Enter your 1st gf name here:");
name=harry.nextLine();
orange obj1=new orange();
obj1.setName(name);
obj1.message();
orange obj2=new orange();
obj2.message();
orange obj3=new orange("xyz");
obj3.message();
}
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.