Use Methods with Parameters

Learn how to Use Methods  with Parameters

Apples Class

import java.util.Scanner;

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

Scanner scanner = new Scanner(System.in);
Tuna tuna = new Tuna();

System.out.println(“Enter your name here”);
String name = scanner.nextLine();

tuna.simpleMessage(name);

}
}

Tuna Class

public class Tuna {
public void simpleMessage(String name){
System.out.println(“Hello ” + name);
}
}

 

 

Share

Leave a Reply

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

Time limit is exhausted. Please reload CAPTCHA.