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

Problem in the code

 
Ganesh Kumar
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
When i execute this code mon=08,mon=09 shows error. Can any one say me what is the problem here


int mon = 0;
if(Month.equals("Jan"))
mon=01;
else if(Month.equals("Feb"))
mon=02;
else if(Month.equals("Mar"))
mon=03;
else if(Month.equals("Apr"))
mon=04;
else if(Month.equals("May"))
mon=05;
else if(Month.equals("Jun"))
mon= 06;
else if(Month.equals("Jul"))
mon= 07;
else if(Month.equals("Aug"))
mon = 08;
else if(Month.equals("Sep"))
mon = 09;
else if(Month.equals("Oct"))
mon=10;
else if(Month.equals("Nov"))
mon=11;
else if(Month.equals("Dec"))
mon=12;
 
Anupam Sinha
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you prefix an integer with zero(0) it becomes an octal literal. Octals have a range from 0 - 7. Hence the error.
 
Ganesh Kumar
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Anupam!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic