|
A Java class is a group of Java methods and variables.
Each Java source code file can contain one public class. The name of this public class must match the name of the Java source code file. If the public class is called "HelloWorld", then the filename would be "HelloWorld.java".
A sample Java class is written below:
public class HelloWorld {
private String name;
public HelloWorld(String name) {
this.name = name;
}
public void sayHello() {
System.out.println("Hello " + name);
}
public static void main(String[] args) {
HelloWorld hw = new HelloWorld("Java Tips");
hw.sayHello();
}
}
|
Related Tips
|
Page 1 of 0 ( 0 comments )
You can share your information about this topic using the form below!
Please do not post your questions with this form! Thanks.