This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is it a bug.............

 
Sandeep Jain
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any one explain me
Why this peace of code compile Properly
import java.lang.*;
class String
{

}
and this doesn't
import java.lang.String;
class String
{

}

------------------
Sandeep Jain
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Explicitly importing a class forces the current compilation process to treat that class as already defined. Importing a whole package just allows the compilation process to "see" those classes, if required.
So trying to redefine String will be an error.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic