A Java class is a group of Java objects all of which have the same or similar properties in common. Classes are logical entities and can never be physical. In a class you may find:
● Fields
● Methods
● Constructors
● Blocks
● Nested classes and an interface
In the Following Java Example, shows how to Create a Class Using Java Example. in this example we show that Syntax of java object creation is <className> objectName = new <classConstructor>; and the Syntax of defining methods of the java class is <modifier> <return-type> method-Name(<optionalParameterList>) <ExceptionList>
Here is the Java Example for the program JavaClassExampleCode :
public class JavaClassExampleCode { public static void main(String []args) { JavaClassExampleCode JavaExample = new JavaClassExampleCode(); JavaExample.setName("Java"); System.out.println("Hello " + JavaExample.getName()); } private String Name; public void setName(String name) { Name = name; //set Parameter to name variable } public String getName() { return Name; //return the setName } }