User Defined Data Type – Class – in Java | Core Java Online Training
This Core Java Online Training “User Defined Data Type – Class – in Java” post explains clearly what is the difference between structure and class in C and Java languages.
User Defined Data type :
- Class is extension to structure in C / C++
- Structure is used to allocate memory to different kinds of data elements.
- After allocating memory to a structure, we can collect the address into a variable of structure type.
- Structure variable is “internal pointer variable”, because it holds address.
- We can access structure elements using dot(.) operator.
Example Code :
Access members using dot operator in Java
int eno ;
String ename ;
float esal ;
public static void main(String args)
Employee e = new Employee();
System.out.println("Eno : "+e.eno);
System.out.println("Ename : "+e.ename);
System.out.println("Esal : "+e.esal);