This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes else with out if Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "else with out if " Watch "else with out if " New topic
Author

else with out if

sandeep Talari
Ranch Hand

Joined: Dec 24, 2007
Posts: 63
import java.util.*;

<blockquote>code:
<pre name="code" class="core">public class BeerExpert
{
public List getBrands(String color)
{
List brands= new ArrayList();
if(color.equals("Green"));
{
brands.add("This is what i sujjested green");
brands.add("And simply proceed for that");
}
else{
brands.add("average");
brands.add("nobody uses this ");
}
return (brands);
}
}
</pre>
</blockquote>

i'm un able to find the problem .

[edit]Add code tags. CR[/edit]
[ July 17, 2008: Message edited by: Campbell Ritchie ]
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Look at this line:

if(color.equals("Green"));

There is a ; that should not be there.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Rakesh Chaudhary
Ranch Hand

Joined: Feb 19, 2008
Posts: 120
Oh that was very Fast jasper

I was compiling it to find the error..


Acquire the unexpected.......
Preparing for SCJP 6
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: else with out if
 
Similar Threads
populating drop down list from database table
Confused by mixed generic type
ArrayList error
Name clash - Type erasure
StringBuffer / StringBuilder methods