0
package Josh_the_bot;

/**
 *
 * @author Jarvis-Main
 */
import java.util.*;
import javax.swing.JOptionPane;
public class Josh_the_bot {

    /**
     * @param args the command line arguments
     * @throws java.lang.InterruptedException
     */
    public static void main(String[] args) throws InterruptedException {
        // TODO code application logic here 
        Scanner namea = new Scanner (System.in);
        int temperature = 0 ;
        String theName;
        theName = "Josh";
        String name = JOptionPane.showInputDialog("Hello What Is Your Name?");
        int namez = Integer.getInteger(name);
        String namereply = JOptionPane.showInputDialog( "O hello" + namez );
        int lel = Integer.parseInt(namereply);

I get this error

Exception in thread "main" java.lang.NullPointerException
at Josh_the_bot.Josh_the_bot.main(Josh_the_bot.java:27)

Java Result: 1

MadProgrammer
  • 343,457
  • 22
  • 230
  • 366
Bhagyesh
  • 700
  • 10
  • 31
  • 2
    You should paste your code in the question, and make sure it's formatted (highlighted and click the curly braces button in the editor). – AfterWorkGuinness Sep 18 '15 at 02:43
  • 1
    `JOptionPane.showInputDialog` might return a `null` if you cancel the dialog, but I'd be more concerned with `int namez = Integer.getInteger(name);` which is likely to fail, as unless the `String` contains nothing but numerical values, it will cause a `NumberFormatException` – MadProgrammer Sep 18 '15 at 02:45
  • @MadProgrammer How do i make it so it take in "names" im new to java :/ thx – Bhagyesh Sep 18 '15 at 02:48
  • `Integer.getInteger` doesn't do what I think you want it to do. It's pulling a `int` property value from the `System.properies` with the specified name or `null` if none exists – MadProgrammer Sep 18 '15 at 03:04

0 Answers0