Results 1 to 5 of 5
Thread: Compiling error
- 11-24-2010, 11:54 AM #1
Member
- Join Date
- Nov 2010
- Posts
- 5
- Rep Power
- 0
Compiling error
Hey,
I am making a app for my school. The purpose is to give in a digit and give the table of it.
my code is:
But when I try to compile it it give's an error that it cant convert Void to java.lang.stringJava Code:void button1_ActionPerformed(java.awt.event.ActionEvent event) { int aantal; aantal = Integer.parseInt(textField1.getText()); int tafel1; tafel1 = aantal * 1; int tafel2; tafel2 = aantal * 2; int tafel3; tafel3 = aantal * 3; int tafel4; tafel4 = aantal * 4; int tafel5; tafel5 = aantal * 5; int tafel6; tafel6 = aantal * 6; int tafel7; tafel7 = aantal * 7; int tafel8; tafel8 = aantal * 8; int tafel9; tafel9 = aantal * 9; int tafel10; tafel10 = aantal * 10; String schrijven; schrijven = textArea1.setText( "1" + "x" + (String.valueOf(aantal)) + "=" + (String.valueOf(tafel1)));
The problem is in the last line.
Can someone help me to point out the problem and/or give the solution?
Robbierut
- 11-24-2010, 12:55 PM #2
You don't need to write String.valueOf(aantal), because compiler makes it automayically. You can change
schrijven = textArea1.setText( "1" + "x" + (String.valueOf(aantal)) + "=" + (String.valueOf(tafel1)));
with
textArea1.setText( "1x" + aantal + "=" + tafel1);
Also, what do you want to do with string 'schrijven'?Last edited by xmdx; 11-24-2010 at 01:02 PM.
- 11-24-2010, 03:37 PM #3
Member
- Join Date
- Nov 2010
- Posts
- 5
- Rep Power
- 0
Okay, Gonna try it as soon as i downloaded the files to my home computer.
The purpose of the string "schrijven" is to write it to a textarea which produces the results of the table.
so in the textfield should say:
1 x (input) = (input * 1)
2 x (input) = (input * 2)
etc.
- 11-24-2010, 04:13 PM #4
You don't need it. Just write
But if u still want to use additional variable, u can do it like this:Java Code:textArea1.setText( "1 x" + aantal + " = " + tafel1);
And stop giving your variables such strange names.Java Code:String newValue = "1 x" + aantal + " = " + tafel1; textArea1.setText(newValue);
- 11-24-2010, 05:00 PM #5
Member
- Join Date
- Nov 2010
- Posts
- 5
- Rep Power
- 0
Similar Threads
-
dos compiling error msg.
By gatehrdy in forum New To JavaReplies: 22Last Post: 09-01-2010, 12:06 AM -
Having error while compiling
By Kodeee in forum New To JavaReplies: 12Last Post: 03-17-2009, 11:08 AM -
Compiling error
By lawksalih in forum New To JavaReplies: 6Last Post: 01-29-2008, 07:26 PM -
Error during compiling
By boy22 in forum New To JavaReplies: 2Last Post: 08-03-2007, 02:42 AM -
Error while compiling
By ai_2007 in forum Advanced JavaReplies: 1Last Post: 07-01-2007, 11:37 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks