나는 정말로 여기에서 격 해할 예정이다. 문자열에서 단어를 뒤집어 쓰려고합니다. StringUtils를 사용하여 가져 오기를 수행하려고합니다. 왜 나는 "기호를 찾을 수 없습니까 ... 방법"을 얻을 수 있습니까? 난 당신이 Apache Commons Lang
를 사용한다고 가정"기호를 찾을 수 없습니다"?
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package mkrsassignment10;
import com.sun.xml.internal.ws.util.StringUtils;
/**
*
* @author mso_
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
//Q1
//int index;
String sentence = "is this a sentence or is it not ";
// 1a
String[] myStringArray = sentence.split(" "); //Split the sentence by space.
String wordLongest = myStringArray[0]; //assign longest word to the first word
for (int i=0; i < sentence.length(); ++i) { //loop through the sentence to find the longest word
if(wordLongest.length() < myStringArray.length)
wordLongest = myStringArray[i];
else
break;
}
System.out.println("The word is: " + "'"+ wordLongest +"'" + " and it is " + wordLongest.length() + " characters long");
// 1b
//for (int i = 0; i < myStringArray.length; i++) {
// myStringArray.toString();
// else
// break;
// 1c
String reversed = StringUtils.reverseDelimited(sentence, " "); // <--- here is the error
System.out.println("Reversed words:" + reversed);
// 1d
sentence = new StringBuffer(sentence).reverse().toString();
System.out.println("Reversed String : " + sentence);
}
}
컴파일러에서 가져 오는 오류 메시지를 게시 할 수 있습니까? (메시지의 일부가 아닌 전체 메시지) – coobird
'com.sun.xml.internal' 내부의 내용을 사용하는 것은 매우 나쁜 습관입니다. 특정 문제를 해결하기위한 또 다른 접근법을 찾을 것을 강력히 권합니다. (예 : Apache Commons Lang의'StringUtils') – skaffman
옙 "심볼을 찾을 수 없습니다. 심볼 : method reverseDelimited (java.lang.String.java.lang.String). location : com.sun.xml.internals.ws..util.StringUtils " – Morten