by Dinesh Thakur Category: Introduction to Java

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
                      }
}

java class example code



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.