MobileMain.java
import java.io.*;
class Mobile{
String company_name;
int screen_size;
DataInputStream d = new DataInputStream(System.in);
void get() throws IOException{
try{
System.out.println("Enter Company name: ");
company_name = d.readLine();
System.out.println("Enter screen size: ");
screen_size = Integer.parseInt(d.readLine());
}
catch(Exception e){
System.out.println("Error!");
}
}
void display(){
System.out.println("Company name is "+company_name);
System.out.println("Screen size is "+screen_size);
}
}
class MobileMain{
public static void main (String [] args) throws IOException{
Mobile m[] = new Mobile[5];
for (int i = 0; i<=4; i++){
m[i] = new Mobile();
}
for (int i = 0; i <= 4; i++){
m[i].get();
}
for (int i = 0; i <= 4; i++){
m[i].display();
}
}
}
Comments
Post a Comment