array test 5
when i run my program this message appears "Exception in thread "main" java.lang.NoClassDeFoundError: org/javadevices/javaclass/ArrayTest5
//The purpose of this program is to demonstrate the use of some simple arrays.
//This package command is more like what one would expect to find when dealing with
// Java applications or libraries that are meant to be widely used.
package org.javadevices.javaclass;
public class ArrayTest5
{
public ArrayTest5()
{
super();
}//end constructor
//This method accepts a String array which contains tool names and and an
// integer array which contains the weight in grams for these tools. Each
// tool name is then printed to standard out along with its weight and the
// number of characters in its name.
public void printTools(String[] pTools, int[] tWeights)
{
int[] toolsLetterCount = getLetterCount(pTools);
int arrayLength = pTools.length;
for (int x = 0; x < arrayLength; x++)
{
System.out.println(pTools[x] + " - " + tWeights[x] + " grams - " + toolsLetterCount[x] + " letters");
}// end for
}//end method
//This method accepts a String array and it returns a new integer array
// which contains the letter count for each word in the String array.
public int[] getLetterCount(String[] words)
{
//Create a new empty integer array which has the same number of members
// as the String array that was passed into this method.
int[] letterCount = new int[words.length];
int x = 0;
while (x < words.length)
{
letterCount[x] = words[x].length();
x++;
}//end while
return letterCount;
}//end method
public static void main(String[] args)
{
ArrayTest5 at = new ArrayTest5();
//Create a reference of type "String array" called 'tools' and then also
// create a new String array object and have 'tools' refer to it. Notice that
// an array can be initialized when it is created by placing the array
// members in braces.
String[] tools = new String[] {"hammer", "wrench", "screwdriver", "hacksaw", "pliers"};
//Create a reference of type "int array" called 'toolWeights' and then
// also create a new int array object and have 'toolWeights' refer to it.
// Notice that an array can be initialized when it is created by
// placing the array members in braces.
int[] toolWeights = new int[] {510,102,105,331,233};
at.printTools(tools, toolWeights);
}//end main
}//end class
|