RosettaCodeData/Task/Classes/Processing/classes-1

18 lines
520 B
Plaintext

class ProgrammingLanguage
{
// instance variable:
private String name;
// constructor (let's use it to give the instance variable a value):
public ProgrammingLanguage(String name)
{
this.name = name;
// note use of "this" to distinguish the instance variable from the argument
}
// a method:
public void sayHello()
{
println("Hello from the programming language " + name);
// the method has no argument or local variable called "name", so we can omit the "this"
}
}