In the question which i am posting i want to know that in order to access the setused()method i create a object named obj1 of array type for class alpha. but if i want to access the same method from class beta and than i would have to create another objects. But is there any way so that i can use the same object ie. obj1 of array type to access the setused() method
import javax.swing.JOptionPane;
public class first()
{
public void main(String args[])
{
alpha[] obj1=new alpha[5];
for(int i-0;i<5;i++)
obj1[i].setused(int 1);
}
}
class alpha
{
private int un_used=5;
private int used=0
public int getun_used()
{
return un_used;
}
public int getused()
{
return used;
}
public void setused(int use)
{
used= use;
}
}
class beta
{
private String name;
}