Classes and Objects in Java Example Programs
Class and Object
import java.io.*;
class ajith
{
public string name;
public int age;
void getdata() throws IOException
{
DataInputStream in=new DataInputStream(System.in);
{
System.out.println("Enter the name and age is:");
name=in.readLine();
age=Integer.parseInt(in.readLine());
}
}
void putdata()
{
System.out.println("The given name is:"name);
System.out.println("The given age is:"+age);
}
}
class selva
{
public Static void main(String args[]) throws IOException
{
ajith a=new ajith();
a.getdata();
a.putdata();
}
}
0 Comments