how to access private vairable in java method
public Class A{
private String myData;
public String getMyData(){
return myData;
}
public void setMyData(String data){
this.myData=data;
}
}
how to access private vairable in java method
public Class A{
private String myData;
public String getMyData(){
return myData;
}
public void setMyData(String data){
this.myData=data;
}
}
private class in java
class Display {
//Private nested or inner class
private class InnerDisplay {
public void display() {
System.out.println("Private inner class method called");
}
}
void display() {
System.out.println("Outer class (Display) method called");
// Access the private inner class
InnerDisplay innerDisplay = new InnerDisplay();
innerDisplay.display();
}
}
public class Main {
public static void main(String args[]) {
// Create object of the outer class (Display)
Display object = new Display();
// method invocation
object.display();
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us