Results 1 to 3 of 3

Thread: [RESOLVED] Declare a const float

  1. #1

    Thread Starter
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Resolved [RESOLVED] Declare a const float

    We're using NetBeans in my Java class and I'm wondering why this wont compile:
    Code:
    public class LoanClass {
        const float HOUSE_15YR = 1.2;
        const float HOUSE_30YR = 1.2;
    
    }
    NetBeans is telling me that there's a loss of data and that I should change the 'float' to a 'double' and when I do that it still wont compile because it's an illegal start of type. What does that mean?

    All I need is a float that's a constant.
    Last edited by JuggaloBrotha; Jan 27th, 2010 at 03:12 PM.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  2. #2
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    710

    Re: Declare a const float

    Use 'static final' instead of 'const'.
    ('const' is a keyword in Java, but it's currently unused).
    David Anton
    Convert between VB, C#, C++, & Java
    www.tangiblesoftwaresolutions.com

  3. #3

    Thread Starter
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: Declare a const float

    Thanks, I did eventually find a page via google that said that.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

Posting Permissions

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



Click Here to Expand Forum to Full Width