Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-15-2008, 10:56 PM   PM User | #1
WheeljackD
New to the CF scene

 
Join Date: Oct 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
WheeljackD is an unknown quantity at this point
Question A quick, basic Java question

I have a quick Java question:

Can one declare both *String* and *float* variables on the same line?

Code:
String float beginBalance, totDeposits, totChecks, totFees;
Or, would I need to have them both on seperate lines. Example:

Code:
String beginBalance, totDeposits, totChecks, totFees;
float beginBal, totDep, totChe, totFe, endBalance;
I need to declare String and float variables for the four I just listed, then I need a fifth one (endBalance) just as a float variable. Thanks in advance.
WheeljackD is offline   Reply With Quote
Old 10-16-2008, 12:44 AM   PM User | #2
Aradon
Moderator-san


 
Aradon's Avatar
 
Join Date: Jun 2005
Location: USA
Posts: 734
Thanks: 0
Thanked 20 Times in 19 Posts
Aradon is on a distinguished road
the second one. You can't have a shared type variable. Unlike perl, you declare a variable with some type, String or otherwise, and it will always be that type.
__________________
"To iterate is human, to recurse divine." -L. Peter Deutsch
Aradon is offline   Reply With Quote
Old 10-16-2008, 01:13 AM   PM User | #3
WheeljackD
New to the CF scene

 
Join Date: Oct 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
WheeljackD is an unknown quantity at this point
Quote:
Originally Posted by Aradon View Post
the second one. You can't have a shared type variable. Unlike perl, you declare a variable with some type, String or otherwise, and it will always be that type.
Thanks .

I had a palm-against-forehead moment after I posted that question, because it would make sense to have them declared separately. I tested out the application, and it works perfectly. I'm a beginner in Java, so forgive the newbie nature of my question.
WheeljackD is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:42 PM.


Advertisement
Log in to turn off these ads.