What is a java class with an example

Java is an object-oriented language, which means that it has constructs to represent objects from the real world. Each Java program has at least one class that knows how to do certain things or how to represent some type of objects.


The java class  is a group/collection of  fields (attributes or properties) and methods (functions).
java class Fields : Fields will describe the properties (state) of a class.
java class Methods : Methods will describe the actions( behavior ) of a class.


java class

java class Syntax:

<public / default > <final/abstract>  class <class_name> {
methods ;

java class Legal class declarations :

public class The_Ice { }  // public modifier

class The_Ice { }  // Default modifier

public abstract class The_Ice { }

public final class The_Ice { }

final class The_Ice { }

abstract class The_Ice { }


Take an example java class called The_Ice. We can create the methods like Turn_ice_into_water and Turn_ice_into_vapor , the fields like Ice_color and Ice_temperature etc.

create a servlet To run a stand alone java class , it requires the main method . 


java class Java Class Example :

Output :

Related Posts :
AES Password Encryption in javascript and decryption in java – servlet
How to call Java Soap Web Service in JavaScript ( JavaScript client for SOAP Web Services )
How to Connect to Oracle from Liferay portlet ( Java Liferay and Oracle integration )
How to Connect Liferay 7 to PostgreSQL ( Java Liferay portlet and PostgreSQL integration )
How to call C# .Net WCF web service in java SOAP client ( Visual Studio 2013 )
How to call PHP RESTful web service in java client
How to call java SOAP web service in php ( php web service client )
Solution to SSLHandshakeException (skip the certificate for Java and LDAP bind)
   [will not be published]

^ <