Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

I need help with this code error "unreachable statement"

843810Oct 9 2009 — edited Oct 9 2009
the error_


F:\Java\Projects\Tools.java:51: unreachable statement <-----------------------------------------------------------------------------------------------------------------THIS
int index;
^
F:\Java\Projects\Tools.java:71: missing return statement
}//end delete method
^
F:\Java\Projects\Tools.java:86: missing return statement
}//end getrecod
^
3 errors


import java.util.*;
import javax.swing.*;
import java.awt.*;


public class Tools//tool class
{
private int numberOfToolItems;
private ToolItems[] toolArray = new ToolItems[10];



public Tools()//array of tool
{
numberOfToolItems = 0;
for(int i = 0; i < toolArray.length; i++)//for loop to create the array tools
{
toolArray[i] = new ToolItems();
}//end for loop

}//end of array of tools

public int search(int id)//search mehtod
{

int index = 0;
while (index < numberOfToolItems)//while and if loop search
{
if(toolArray[index].getID() == id)

return index;
else
index ++;



}//en while and if loop
return -1;
}//end search method

public int insert(int id, int numberInStock, int quality, double basePrice, String nm)//insert method
{
if(numberOfToolItems >= toolArray.length)
{
return 0;
int index;
index = search(id); <-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------HERE

if (index == -1)
{
toolArray[index].assign(id,numberInStock, quality, basePrice,nm);
numberInStock ++;

return 1;


}//end if index
}//end if toolitem array

return -1;
}//end insert method

public int delete(/*int id*/)//delete method
{

}//end delete method

public void display()//display method
{
for(int i = 0; i < numberOfToolItems; i++)
{
//toolArray.display(g,y,x);
}

}//end display method


public String getRecord(int i)//get record method
{
// return toolArray[i].getName()+ "ID: "+toolArray[i].getID()
}//end getrecod

}//end class

Edited by: ladsoftware on Oct 9, 2009 6:08 AM

Edited by: ladsoftware on Oct 9, 2009 6:09 AM

Edited by: ladsoftware on Oct 9, 2009 6:10 AM

Edited by: ladsoftware on Oct 9, 2009 6:11 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 6 2009
Added on Oct 9 2009
3 comments
189 views