Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Regular Coder Aradon's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    734
    Thanks
    0
    Thanked 20 Times in 19 Posts
    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

  • #3
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •