Results 1 to 6 of 6
- 07-30-2009, 10:17 PM #1
Member
- Join Date
- Jul 2009
- Posts
- 46
- Rep Power
- 0
Using if statements to determine integers.
I'm trying to figure out how to make my ints come available depending on something else.
like
Java Code:if (currentDisplayNum == 1) { int RAMsize1 = 3900; int RAMsize2 = 1900; double CPUinfo1 = 2.4; double CPUinfo2 = 1.8; }else if (currentDisplayNum == 2) { int RAMsize1 = 1900; int RAMsize2 = 900; double CPUinfo1 = 1.4; double CPUinfo2 = 0.8; ] This doesn't work.
- 07-30-2009, 10:47 PM #2
Member
- Join Date
- Jul 2009
- Posts
- 8
- Rep Power
- 0
I'm not sure i understand your question.
But did you try to declare your variables before the if statement?
-
Yep, webbusiness23 has given you the correct answer. Declare your RAMsize1, RAMsize2, CPUinfo1, CPUinfo2 variables before the if block so that they will be visible inside the if/else blocks and also still visible after the if/else blocks have completed.
- 07-31-2009, 11:55 AM #4
Member
- Join Date
- Jul 2009
- Posts
- 6
- Rep Power
- 0
More general information you check out the topic scope of variables,
every programming language has own scope implementation and there are various type of scope and binding. In java every code block, in other words matching curly braces defines a scope and all the definition maded in this scope are valid in this scope. i hope i can be helpful
- 07-31-2009, 01:02 PM #5
AR on user arkins for off topic spam.
db
-
Similar Threads
-
How to determine CPU usage using Java?????
By JavaEmpires in forum New To JavaReplies: 5Last Post: 03-16-2011, 04:49 AM -
How do you determine the width of a TableColumn heading?
By The Gonif in forum SWT / JFaceReplies: 2Last Post: 03-01-2011, 01:30 AM -
determine the type of card hand
By javaman2 in forum New To JavaReplies: 7Last Post: 01-04-2009, 05:11 PM -
how to determine the primary key
By osval in forum JDBCReplies: 1Last Post: 08-07-2007, 02:31 AM -
How to determine if the value of a JTextField is double
By nemo in forum New To JavaReplies: 1Last Post: 05-20-2007, 11:19 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks