+ 1
What is the issue with below Java Code
Hi While executing below code it is not giving any output. Can anyone clarify what is the issue with below code. public PrivateClassVl { public String name; public String getName() { return this.name; } public void setName(String name_1) { this.name = name_1; } public static void main(String[] args) { PrivateClassVl clsInstnc = new PrivateClass(); clsInstnc.setName("Test_name"); String nameVl = clsInstnc.getName(); System.out.println("Name value is : " + nameVl); } }
2 Réponses
+ 6
"public PrivateClassVI"
There was no class keyword used.
->
public class PrivateClasPVI
"new PrivateClass()"
Needs to be:
new PrivateClassVI();
0
Hi
Thanks for clarifying the issue. Now its working fine. I'm just now started learning Java.
public class PrivateClassVl {
public String name;
public String getName() {
return this.name;
}
public void setName(String name_1) {
this.name = name_1;
}
public static void main(String[] args) {
PrivateClassVl clsInstnc = new PrivateClassVl();
clsInstnc.setName("Test_name");
String nameVl = clsInstnc.getName();
System.out.println("Name value is : " + nameVl);
}
}