Java class wizard
Class wizard is a tool that makes it easy and fast to generate code for a class by specifying the name and type of the data members. A constructor, find (and set) functions, and a toString function are generated automatically.
In this tutorial we are going to create a class called Person, and which has three data members: Name, address and telephone, all of type String.
1. Press key in the program, you find this button on the left in the program under the Java tab.
2. In the dialog that pops up you can enter the name of the Class, the names of the data members and of course the data member types.
3. First select String in Data type drop down menu, and type telephone, in the "Data member name" field. Press "Add.." to add the data member to the list of data members :) If you want a set function to the code that is generated, click on the box next to the data member in the list.
4. Do the same as in 3, for the data members Address and Name. Press OK to generate the code.
5. The code that are generated looks like this:
class Person {
private String name;
private String address;
private String telephone;
public Person(String startName, String startAddress, String startTelephone) {
name = startName;
address = startAddress;
telephone = startTelephone;
}
public String findName() {
return name;
}
public String find Address() {
return address;
}
public String find Telephone() {
return telephone;
}
public String toString() {
return "Person - "+" name: "+name+" address: "+address+" telephone: "+ telephone;
}
}
Back to product info page