Writing A class

class and constructor

Class :- Class is a collection of data members and member functions. Member functions are also called as properties or behavior of that class. lets see below example.


public class myClassDemo {
int i;
double j;
char c;
String str;

void display()
{
System.out.println("i=" +i);
System.out.println("j=" +j);
System.out.println("c=" +c);
System.out.println("str=" +str);
}

public static void main(String args[])
{

myClassDemo ob= new myClassDemo();
ob.i=10;
ob.j=10.5
ob.c='a';
ob.str="Amol"

ob.display();
}
}