Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Is the Java Compiler retarded?

Name: Anonymous 2009-10-27 3:15

Its telling me I need a return statement on the last line of my method even though that part can never be executed.. I am a novice at Java and I am teaching myself.. so is it just me that has bad coding style or is the java compiler a bit too OCD?

Name: Anonymous 2009-10-27 3:30


int foo(int bar)
{
  if (bar == 1)
  {
     // Do stuff
     return bar;
  }
  else
  {
     // Do stuff
     return 0;
  }
}


...should become...


int foo(int bar)
{
  if (bar == 1)
  {
     // Do stuff
     return bar;
  }
  else
  {
     // Do stuff  
  }
 
  return 0;
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List