package com.sudhirtheindian2.java123;
public class MyConstructor {
int x;
String name;
MyConstructor(){
x=0;
name=null;
}
void display(){
System.out.println(x+" "+name);
}
public static void main(String[] args) {
MyConstructor c = new MyConstructor();
c.display();
// What is constructor in java ?
// constructor is a special type of method
// whose name is same as class name
// important notes for constructor--------
// 1 the main purpose of constructor is initialize the object
// 2 every java class has a constructor
// if you not create constructor then
// java create autumatic default constructor
// 3 constructor is autmatically called
// at the time of object creation
// 4 constructor never contain any return types
// syntax
// constructor name as a class name
}
}
Computer Storage Units Converter Computer Storage Units Converter From: Bytes Kilobytes Megabytes Gigabytes Terabytes Value: To: Bytes Kilobytes Megabytes Gigabytes Terabytes Convert
टिप्पणियाँ
एक टिप्पणी भेजें