L
L
LaYof2016-07-13 18:39:02
Java
LaYof, 2016-07-13 18:39:02

Java.Lang.NullPointerException, What should I do about this leprosy?

I tried to put the text in areatex, then (of course, after the next zero), put the character in choose, still zero. Help me please!

public class Main {

    public static void main(String[] args) {
       Lois kit = new Lois();
        kit. areatex.setText(kit.fdfe);
        kit.choose.setText(String.valueOf(kit.symb.length));
        kit.frame.setSize(500,500);//тут подчеркивается kit и выдает variable kit might not have been initialized
        kit.frame.setVisible(true);
        kit.frame.add(kit.areatex , BorderLayout.NORTH);
        kit.frame.add(kit.choose , BorderLayout.CENTER);
        kit.frame.add(kit.areaa , BorderLayout.SOUTH);
        kit.frame.add(kit.tellma , BorderLayout.EAST);
        kit.areatex.setSize(10,1);
        kit.choose.setSize(10,1);
        kit.areaa.setSize(10,1);
        kit.tellma.setSize(30,30);
        kit.areaa.setText(kit.touser);

    }
    }

public class Lois {
        Pitter husband;
        JFrame frame = new JFrame();
        int x = 0;
        JTextArea areatex = new JTextArea();
        JTextArea choose = new JTextArea();
        JTextArea areaa = new JTextArea();
        JButton tellma = new JButton();
        String fdfe ="Не поверишь, но от этой надписи зависит работа программы." ;
        String infoof = areatex.getText();
        String touser = "Ваш символ встретился в данном вами предложении ровно " + husband.wife.x;
        String abchos = choose.getText();
        char[] choise = abchos.toCharArray();
        String pw = "n";
        char[] symb = pw.toCharArray();
}

public class Pitter {

    Lois wife;
        ActionListener WhatDo = new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                wife.symb = wife.infoof.toCharArray();
                for (int i = 0; i < wife.symb.length; i++) {
                    if (wife.symb[i] == wife.choise.length) {
                        wife.x = wife.x + 1;

                    }
                }
            }

        };
    }

I was expecting dirty tricks from areaa, but two links constantly pop up in the console, when you click on them, the cursor in a mean way flies to the lines:
String touser = "Ваш символ встретился в данном вами предложении ровно " + husband.wife.x;
    Lois kit = new Lois();

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Shishkin, 2016-07-13
@LaYof

String touser = "Your character was encountered in the sentence you provided exactly " + husband.wife.x;
husband == null

B
bromzh, 2016-07-13
@bromzh

This is a sign from above that it's time to start learning how to use the debugger.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question