In my last post I have discussed about Float Type variable and how to add two float type variable.
Here I will share you about how to use and call a class from another class in Java.
Here is the example:
class Room
{
float length;
float breadth;
void getdata(float a, float b)
{
length=a;
breadth=b;
}
}
class RoomArea
{
public static void main(String args[])
{
float area;
Room room1=new Room();
room1.getdata(14,10);
area=room1.length*room1.breadth;
System.out.println(“Area:”+area);
}
}
thanks for grow my knowledge
LikeLike
very good explanation
LikeLike