javac#complex-data-types

how does a class as a data type or return type works. Can some one please tell,


public class className{  
int number;  
string name;  
public ClassName(int d) {  //What will return from this method??
    d = 10 ;  
    name = "ABC";  
}  

}

I cant figure out how does a class as a data type or return type works. Can some one please tell, show or teach me how it works.


Solution

  • Think of a class as a custom datatype. We have strings, which represent words. We have ints, which represent whole numbers. There is no native datatype for Node, which you want to have a data and next property. As you pass the Node class like you would any other datatype, but will have information on the Node data and Node next, not just a string or int.