Lol Omg dude
Member
- Joined
- May 16, 2007
- Sythe Gold
- 0
- Messages
- 85
Ok I don't understand how the commands return, set, get work on Java with multiple methods and instances. Can someone explain to me what is going on exactly?
Here's a sample code:
apples.java
oranges.java
Here's a sample code:
apples.java
Code:
import java.util.Scanner;
class apples {
public static void main (String args[]){
Scanner input = new Scanner(System.in);
oranges orangesObject = new oranges ();
System.out.println("Enter name here: ");
String temp = input.nextLine();
orangesObject.setName(temp);
orangesObject.saying();
}
}
oranges.java
Code:
public class oranges {
private String personName;
public void setName(String name)
{
personName = name;
}
public String getName()
{
return personName;
}
public void saying()
{
System.out.printf("The name is %s", getName());
}
}











