Original Post
I have two classes, one class has a method type as the name of the other class. I want to return an object and print it in main.
Please help. I have tried different versions some dont compile, but the one below does. Although it compiles it just outputs a random number which I am guessing is a memory location.
Please help. I have tried different versions some dont compile, but the one below does. Although it compiles it just outputs a random number which I am guessing is a memory location.
public class Big
{
public Big()
{
}
public AnotherClass getNumber(int x)
{
AnotherClass obj = new AnotherClass(1, 2, 3);
obj.getY(); // a method inside the Class named AnotherClass
return obj; // I want to return this object, but of course this fails.
}
}
// in main
Big bigObj = new Big();
System.out.println(bigObj.getNumber(5));