error: cannot find symbol
Publicado por David (1 intervención) el 11/07/2012 12:31:41
Antes que nada, perdón por las molestias, ya se que este es un problema de los mas comunes, pero buscando por google "error: cannot find symbol" y la línea entera en la que me aparece esta frase salen muchísimos resultados, y no encontré lo que buscaba.
Estoy empezando a programar en java con el libro Head First Java, y en uno de los programas de ejemplo. Este:
public class PhraseOMatic {
public static void main (String[] args) {
//make three sets of words to choose from. Add your own!
String[] wordListOne = {"24/7", "multi-Tier", "30,000 foot", "B-to-B", "win-win", "front-end", "web-based", "pervasive", "smart", "six-sigma", "critical-path", "dynamic"};
String[] wordListTwo = {"empowered", "sticky", "value-added", "oriented", "centric", "distributed", "clustered", "branded", "outside-the-box", "positioned", "networked", "focused", "leveraged", "aligned", "targeted", "shared", "cooperative", "accelerated"};
String[] wordListThree = {"process", "tipping-point", "solution", "architecture", "core competency", "strategy", "mindshare", "portal", "space", "vision", "paradigm", "mission"};
//find out how many words are in each list
int oneLenght = wordListOne.lenght;
int twoLenght = wordListTwo.lenght;
int threeLenght = wordListThree.lenght;
//generate random numbers
int rand1 = (int) (Math.random() * oneLenght);
int rand2 = (int) (Math.random() * twoLenght);
int rand3 = (int) (Math.random() * threeLenght);
//now build a phrase
String phrase = wordListOne[rand1] + " " + wordListTwo[rand2] + " " + wordListThree[rand3];
//print out the phrase
System.out.println("What we need is a " + phrase);
}
}
La cmd al ejecutar javac me suelta esto:
PhraseOMatic.java:8:error:cannot find symbol
int one Lenght = wordListOne.lenght;
----------------------------------------^(en el punto)
symbol: variable lenght
location: variable wordListOne of type String[]
Me dice lo mismo para las líneas 9 y 10.
Alguien me puede decir como puedo solucionar esto?.
GRACIAS
Estoy empezando a programar en java con el libro Head First Java, y en uno de los programas de ejemplo. Este:
public class PhraseOMatic {
public static void main (String[] args) {
//make three sets of words to choose from. Add your own!
String[] wordListOne = {"24/7", "multi-Tier", "30,000 foot", "B-to-B", "win-win", "front-end", "web-based", "pervasive", "smart", "six-sigma", "critical-path", "dynamic"};
String[] wordListTwo = {"empowered", "sticky", "value-added", "oriented", "centric", "distributed", "clustered", "branded", "outside-the-box", "positioned", "networked", "focused", "leveraged", "aligned", "targeted", "shared", "cooperative", "accelerated"};
String[] wordListThree = {"process", "tipping-point", "solution", "architecture", "core competency", "strategy", "mindshare", "portal", "space", "vision", "paradigm", "mission"};
//find out how many words are in each list
int oneLenght = wordListOne.lenght;
int twoLenght = wordListTwo.lenght;
int threeLenght = wordListThree.lenght;
//generate random numbers
int rand1 = (int) (Math.random() * oneLenght);
int rand2 = (int) (Math.random() * twoLenght);
int rand3 = (int) (Math.random() * threeLenght);
//now build a phrase
String phrase = wordListOne[rand1] + " " + wordListTwo[rand2] + " " + wordListThree[rand3];
//print out the phrase
System.out.println("What we need is a " + phrase);
}
}
La cmd al ejecutar javac me suelta esto:
PhraseOMatic.java:8:error:cannot find symbol
int one Lenght = wordListOne.lenght;
----------------------------------------^(en el punto)
symbol: variable lenght
location: variable wordListOne of type String[]
Me dice lo mismo para las líneas 9 y 10.
Alguien me puede decir como puedo solucionar esto?.
GRACIAS
Valora esta pregunta


0