Software & Finance





Java - Struct - Simulate with Class





In Java, class is a keyword. Using class, we can implement all object oriented programming language concepts. All the members declared in Java classes are private with provides access to the package by default. We can also have protected access level to for derived classes and public access level for any functions or classes.

 

There is no Struct in Java unlike C, C++ or C#. We need to live with java class with only members to simulate C style struct.


NOTE: No virtual or override keyword in Java.

 

 

Source Code


import java.io.*;

 

 

class Student

{ 

    public String Name;

    public int age;

}

 

 

 

Output


None