+ 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.

4th Dec 2018, 4:03 PM
pedro
pedro - avatar
3 Antworten
+ 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); } }
4th Dec 2018, 4:22 PM
Rishi Anand
Rishi Anand - avatar
+ 2
It's possible to have classes nested in classes
4th Dec 2018, 4:16 PM
Dlite
Dlite - avatar
0
Thanks everyone, I'm understand now.
4th Dec 2018, 4:27 PM
pedro
pedro - avatar