Create a Mobile class with properties, which can be set once while creating object using constructor arguments. Create getProperties() methods which are having public access modifiers.
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
System.out.println("Enter properties:");
String pr=in.next();
Mobile m=new Mobile(pr);
System.out.println(m.getProperties());
}
}
class Mobile{
private String properties;
public Mobile(String p){
properties=p;
}
String getProperties(){
return properties;
}
}
Comments
Leave a comment