सीधे मुख्य सामग्री पर जाएं

Computer Storage Units Converter

Computer Storage Units Converter Computer Storage Units Converter From: Bytes Kilobytes Megabytes Gigabytes Terabytes Value: To: Bytes Kilobytes Megabytes Gigabytes Terabytes Convert

#45 What is Private Constructor in Java ? How to create private constructor in Java

package com.sudhirtheindian2.java123;

public class PConstructor {

int a;
String name;
private PConstructor(){
a=45;
name="indian";
System.out.println(a+" "+name);
}


public static void main(String[] args) {
PConstructor p = new PConstructor();


// What is private Constructor in java ?

// In java, it is possible to write a constructor as a private
// but according to the rule we can not acceess
// private members outside of the class

}
}

//class B{
//// PConstructor p = new PConstructor();
//}

टिप्पणियाँ

इस ब्लॉग से लोकप्रिय पोस्ट