This is example for java programming
Making a welcome program for the user, the user has a name and a hobby.
Create two files namely pengguna.java and userInterface.java that contains the following:
In pengguna.java file
import java.io. *; / / retrieve the standard classes available in java
public class users
(
/ / Declaration attribute
private String name;
private String hobby;
/ / Method declaration
/ / No return value
/ / Be used void
public void setNamadanHobi (String name, String Hobbies)
(
this.nama = name;
this.hobi = Hobbies;
)
/ / Method to display the names and hobbies object to be created
public void lihatDataDiri ()
(
System.out.println ("\ n" + this.nama + "which has a hobby:" + this.hobi);
)
)
In userInterface.java file
import java.io. *;
public class userInterface
(
public static void main (String args [])
(
a user user = new object ();// creation of user classes
a.setNamadanHobi ("Stephen", "read ");// give a name and a hobby in objects
System.out.println ("\ n \ tWelcome");
a.lihatDataDiri ();// calls method for manampilkan names and hobbies
)
)
Then at the command prompt move to the directory this file is located and then do this command (javac to compile java programs while running the program)
Basic java programming android(2)
posted by :
learningandroid
Friday, July 2, 2010
Label: java android, Tutorial
Subscribe to:
Post Comments (Atom)
0 comment:
Post a Comment