Results 1 to 6 of 6
Thread: [SOLVED] what error do i have?
- 01-29-2009, 03:56 AM #1
Member
- Join Date
- Jan 2009
- Posts
- 90
- Rep Power
- 0
[SOLVED] what error do i have?
variable a might not have been initialized
if ((12000 <= a )&&(a < 12321)){
^
what is this mean?
im learning about loops at this point.Java Code:public class tt{ public static void main(String[]args){ int n = 1; double a; while ( n < 999) a = Math.pow(n, 2); if ((12000 < a )&&(a < 12321)){ System.out.println("The smallest n such that n^2 > 12,000 is " + n); } n++; } }Last edited by PureAwesomeness; 01-29-2009 at 04:03 AM.
-
There is only one variable in that line that trips the error. You have declared the variable, but where have you initialized it -- where have you set its initial value? Bottom line: when declaring variables (not counting variables declared in the class scope), you need to initialize them to something at declaration.
- 01-29-2009, 04:03 AM #3
Member
- Join Date
- Jan 2009
- Posts
- 90
- Rep Power
- 0
so i need to assign a to something like a number first?
- 01-29-2009, 04:06 AM #4
Member
- Join Date
- Jan 2009
- Posts
- 90
- Rep Power
- 0
ok i got it thanks
- 01-29-2009, 04:36 AM #5
glad your prob is solved.
if solved, please mark it as solved by using Thread Tools at the top toolbars.USE CODE TAGS--> [CODE]...[/CODE]
Get NotePad++ (free)
- 01-29-2009, 04:38 AM #6
Member
- Join Date
- Jan 2009
- Posts
- 6
- Rep Power
- 0
Similar Threads
-
Diference Between compiler error Garbage collection and Runtime Error?
By makpandian in forum New To JavaReplies: 3Last Post: 01-23-2009, 08:53 AM -
error 530 error authentication required
By rgale in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 05-12-2008, 04:28 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks