wood burning stoves 2.0*
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
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: 14146
    
  18

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