Results 1 to 2 of 2

Thread: Declaration

  1. #1
    asifahmed is offline Member
    Join Date
    Apr 2008
    Rep Power

    Default Declaration

    I am not undersranding the following,
    when we declare variable and write expression,
    short a=5;
    short b=5;
    short c=0;
    the compile won't be able to compile because the expression throw 32 bit result;
    but when we write like this
    the compile accomodate the type according the variable.

    can anyone answer to this

  2. #2
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    NewEngland, US
    Rep Power


    The operator + doesn't work on variables in a mathematical addition operation, it requires literal primitives such as 1, 2, 3, 4 .... Review this and see if it helps.

    Welcome to the forums and see you around!
    Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
    Want to voice your opinion on your IDE/Editor of choice? Vote now!
    Got a little Capt'n in you? (drink responsibly)

Similar Threads

  1. public declaration ('undeclaring')
    By Jadellll in forum New To Java
    Replies: 2
    Last Post: 03-17-2008, 09:50 PM
  2. multiple declaration of a variable
    By eva in forum New To Java
    Replies: 2
    Last Post: 01-28-2008, 10:17 AM
  3. Array size declaration
    By JT4NK3D in forum New To Java
    Replies: 3
    Last Post: 01-18-2008, 11:37 PM
  4. JSP Declaration Directive
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-10-2007, 06:42 PM
  5. Function declaration problem.
    By snooze-g in forum Advanced Java
    Replies: 3
    Last Post: 07-18-2007, 09:15 PM

Posting Permissions

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