Girish
Girish

Reputation: 1

How to test a java class with method

I am newbie to java, so please excuse my ignorance. I tried to find this answer online but could not get the exact solution, so please help

I have created a java class, which has a method that accepts three parameters, the program accepts that parameter and insert those three parameters in the database.

Now I want to test this program and not sure how to do, I want that when I run this program, program should force me to enter three values which are input to the method

Kindly help

Upvotes: 0

Views: 69

Answers (1)

DucRP
DucRP

Reputation: 139

If you want a program to read some input and call a function with three String arguments, this code will work. Just look up the Scanner class in java.util.

import java.util.Scanner;

public class GetParameters
{
    public static void main(String [] args)
    {
        Scanner scan = new Scanner(System.in);
        String s1 = scan.nextLine();
        String s2 = scan.nextLine();
        String s3 = scan.nextLine();
    }

    public static void yourMethod(String s1, String s2, String s3)
    {
        // your code here
    }
}

Upvotes: 1

Related Questions