Many Methods and Instances in Java

Learn how to use Many Methods and Instances

Apples Class

import java.util.Scanner;

class Apples {
public static void main(String[] args) {

Scanner input = new Scanner(;
Tuna tuna = new Tuna();
System.out.println(Enter the name of your first gf);

String temp = input.nextLine();




Tuna Class

public class Tuna {

private String girlName;

public void setName(String name){
girlName = name;

public String getName(){
return girlName;

public void saying(){
System.out.printf(“Your first gf name is %s”, getName());



Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.