[661] in java-interest

home help back first fref pref prev next nref lref last post

Java compiler is trying too hard for me

daemon@ATHENA.MIT.EDU (Tientien Li)
Wed Jul 12 13:13:35 1995

Date: Wed, 12 Jul 1995 08:54:23 -0700
From: li@deming.Jpl.Nasa.Gov (Tientien Li)
To: java-interest@java.sun.com
Cc: li@deming.Jpl.Nasa.Gov

Hi,

The Java compiler "javac" won't let me do the following type of code:

   class smartjavac {
      public void init() {
         int x;
         for (int i=0; i<3; i++) {
            if (i == 0)  x = i;
            else if (i == 1)  x = i;
            else x = i;
         }
         System.out.println("ValueOfX is " + x );
      }
   }

The compiler print out the following message and won't generate 
any class code.

   smartjavac.java:9: Variable x may not have been initialized.
           System.out.println("ValueOfX is " + x );
                                            ^
   1 error

I've tried several compiler options including "-nowarn", but got the
same result.

Any fix for this problem?

--
Tientien Li
li@deming.jpl.nasa.gov
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post