Commit 1d96c957 authored by a.guest's avatar a.guest

Added name variable, getter and setter

parent 39947ec8
Pipeline #150 failed with stages
......@@ -9,6 +9,9 @@ public class ClassDemo {
System.out.println("2 + 5 = " + hello.add2Num(2, 5));
System.out.println("My name is " + hello.getName());
hello.setName("Andy");
System.out.println("My name is " + hello.getName());
}
}
public class HelloWorld {
String name = "default name";
public void sayHello()
{
System.out.println("Hello World");
......@@ -11,4 +13,15 @@ public class HelloWorld {
return a+b;
}
public void setName(String newName)
{
name = newName;
}
public String getName()
{
return name;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment