import javax.swing.JOptionPane;

public class Test1 {
  public static void main (String[] args) {
    
    // Method 1
    Test3 method1 = new Test3(); // is this the method to call Test3()?
    JOptionPane.showMessage (null, method1

    // Method 2
    JOptionPane.showMessageDialog (null, Test3());

    // Method 3
    JOptionPane.showMessageDialog (null, Test3.toString());
  }
}

class Test2 {
  public String Test3(String Test4) {
    if(...) {
      x += x.toString();
    }
    return Test4;
  }

  public String toString() {
    return y;
  }
}

If the code looks like this, how can I call Test4 onto main?

I wrote 3 methods I've tried on main method but none of them work... :(

One more question

I need to send the user input to public String Test3

So user input = String Test..

public class Test1 {
  public static void main (String[] args) {
    String input = new String();
    Test3(input);
  }
}

Would this code send String input to Test3 method?

minimi, I think you are getting confused between calling a method, and constructing a new object using a constructor. A constructor is a special member function of a class that is used to create objects of that class. It is special since it has the same name as the class itself, has no return type, and is invoked using the new operator. In your code, the line

Test3 method1 = new Test3(); // is this the method to call Test3()?

is calling the constructor of the class Test3, and by that creating a new instance of the class Test3.
A method is an ordinary member function of a class. Each method has its own name, a return type (if the method doesn't return anything the return type is void), and is invoked using the dot operator. In your code, and example for using a method is the line

JOptionPane.showMessageDialog (null, Test3());

Please comment your code in each line, describing what you are trying to do in that line, and we will try to help you.

This article has been dead for over six months. Start a new discussion instead.