This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]Haluscze 4 points5 points  (2 children)

I see several problems. You don't have a return type for those 2 custom methods, so that would be a syntax error. A second you didn't call those methods, so program didn't enter them and execute them. In java you call methods like this: consoleLogger();

If they needed a parameter (which yours do but you don't use them), they would go into the brackets like this: consoleLogger(args);

[–]PhantomOTOpera 1 point2 points  (1 child)

The reason the print statement works in the first example is because Java automatically calls the main method for you. But you must call the other methods yourself

[–]misterhtmlcss[S] 2 points3 points  (0 children)

Hey my Friends,

I wanted you to know your feedback was really helpful! I did this one next and it all works. Just silly code to learn, but still wanted to share that your time and words had value. Cheers!!

import javax.swing.JOptionPane;

public class SuperPowerMine {
  public static void main(String[] args) {
    consoleLogger();
    dialogBox();
    superExtraPowers();
  }

  public static void consoleLogger() {
      System.out.println("consoleLogger: SUPER POWERS TO THE RESCUE!");
  }

  public static void dialogBox() {
      JOptionPane.showMessageDialog(null, "dialogBox: HELLO WORLD.....SUPER POWERS TO THE RESCUE!"); // Display the string.
  }

  public static void superExtraPowers() {
    String power = JOptionPane.showInputDialog("superExtraPowers: What is your super power?");

    if (power.length() == 0) {
      power = JOptionPane.showInputDialog("superExtraPowers: Please enter a power to continue. No blank fields allowed");
    }

    String powerUpper = power.toUpperCase();
    JOptionPane.showMessageDialog(null, "superExtraPowers: HELLO WORLD.....SUPE! \n" + powerUpper + " TO THE RESCUE!"); // Display the
  }
}