+ 1
Class in Java
Hi everyone, I'm new in Java, and i wanna know if is it possible for a class to be an attribute of another class? I'm have googled this but i can't find this... But I'm thinking that it's possible because Strings can be attributed and strings are part of a class(i think)... Pls reply me.
3 Réponses
+ 3
As you are new to java...m showing you a very basic example
class Xyz
{
int num = 10;
}
public class Main
{
public static void main(String args[])
{
Xyz ref = new Xyz();
System.out.print(ref.num);
}
}
+ 2
It's possible to have classes nested in classes
0
Thanks everyone, I'm understand now.