I need help fixing my telephone keypad application, it will compile but when I run it, it doesnt work someone please help

Recommended Answers

All 3 Replies

I need help fixing my telephone keypad application, it will compile but when I run it, it doesnt work someone please help

it throws ArrayIndexOutofBound exception.. reason is that your Button array size is 12
--------------------------------
keys = new Button[12];
----------------------------------
while you are trying to add element at 13th position
keys[12] = new Button("#"); this will throw exception
change to ==> keys = new Button[13];
it will work

it throws ArrayIndexOutofBound exception.. reason is that your Button array size is 12
--------------------------------
keys = new Button[12];
----------------------------------
while you are trying to add element at 13th position
keys[12] = new Button("#"); this will throw exception
change to ==> keys = new Button[13];
it will work

So it should be keys[12] = new Button("#");

So it should be keys[12] = new Button("#");

it worked but now when I run it i get java.lang.NullPointerException

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.