누구든지 여기에서 무슨 일이 벌어 질 수 있을지 생각하고 있습니까?String.charAt (0)가 아무 것도 출력하지 않고 문자 유형이 "16"이 될 수있는 원인은 무엇입니까?
첫 번째 블록은 내가 일반적으로 볼 것으로 예상되는 것을 보여줍니다. '문제'문자열이 색인 된 똑같은 것으로 대체되었지만 이전에는 결코 실행되지 않았던 문자열의 첫 번째 문자가 색인 '0'에 있습니다. 출력 제공
public void finderTest(){
String theDoc = "Hello, I want this to work, and work well! Do you think it will work, and if not, why not?";
//String wordOne = "abc"; // old, pre-used string, used to hold a comma.
String wordOne = "abc";// new, never run before with a comma
String wordTwo = "and";
System.out.println("Type of character at index '0' in theDoc: "+Character.getType(theDoc.charAt(0)));
System.out.println("Character at index '0' in theDoc: "+theDoc.charAt(0));
System.out.println();
System.out.println("All of wordOne: "+"'"+wordOne+"'");
System.out.println("Type of character at index '0' in wordOne: "+Character.getType(wordOne.charAt(0)));
System.out.println("Character at index '0' in wordOne: "+wordOne.charAt(0));
System.out.println();
System.out.println("Type of Character at index '0' in wordTwo: "+Character.getType(wordTwo.charAt(0)));
System.out.println("Character at index '0' in wordTwo: "+wordTwo.charAt(0));
}
:
/*
Type of character at index '0' in theDoc: 1
Character at index '0' in theDoc: H
All of wordOne: 'abc'
Type of character at index '0' in wordOne: 2 // okay
Character at index '0' in wordOne: a // okay
Type of Character at index '0' in wordTwo: 2
Character at index '0' in wordTwo: a
*/
제 2 블록이 주석 '새'문자열 및 'wordOne'의 첫 번째 문자가 아무것도 없다. null 문자 또는 개행 문자가 아닙니다. 그 변수를 사용하여 'theDoc'에서 쉼표를 찾았습니다 ...하지만 실행했을 때 '0'인덱스는 아무것도 유지하지 않았고 인덱스 1에는 쉼표가있었습니다. 문자열을 복사하여 붙여 넣으면 문제가 남아 있습니다. 그러나 주석을 달아서 삭제하면 문제를 해결할 수 있습니다. 이 같은 문제를 야기 자바에서 쉼표 나 기호에 대해 뭔가가
/*
Type of character at index '0' in theDoc: 1
Character at index '0' in theDoc: H
All of wordOne: 'abc'
Type of character at index '0' in wordOne: 16 // What does this mean?
Character at index '0' in wordOne: // where is the a? (well, its in wordOne index '1'... but why??)
Type of Character at index '0' in wordTwo: 2
Character at index '0' in wordTwo: a
*/
있습니까 :
public void finderTest(){
String theDoc = "Hello, I want this to work, and work well! Do you think it will work, and if not, why not?";
String wordOne = "abc"; // now running old string, used to hold comma
//String wordOne = "abc";
String wordTwo = "and";
System.out.println("Type of character at index '0' in theDoc: "+Character.getType(theDoc.charAt(0)));
System.out.println("Character at index '0' in theDoc: "+theDoc.charAt(0));
System.out.println();
System.out.println("All of wordOne: "+"'"+wordOne+"'");
System.out.println("Type of character at index '0' in wordOne: "+Character.getType(wordOne.charAt(0)));
System.out.println("Character at index '0' in wordOne: "+wordOne.charAt(0));
System.out.println();
System.out.println("Type of Character at index '0' in wordTwo: "+Character.getType(wordTwo.charAt(0)));
System.out.println("Character at index '0' in wordTwo: "+wordTwo.charAt(0));
}
어느 출력을 제공? 나는 문자 배열을 사용하여 모든 것을 다시 빌드하기 위해 작업 공간을 청소 해 보았습니다. 그리고 아무것도 변경되지 않았습니다 ... 어떤 그램이 ", and"와 같은 경우에는 문장 내에서 'ngrams'색인을 찾는 데 큰 문제가 있습니다. 어느 날 밤 어젯밤에 일하고 있었고 갑자기 일이 시작되지 않았습니다. 나는 꽤 혼란 스럽다.
아이디어가 있으십니까?
감사합니다,
앤드류
아, 너의 (거의) 정확하게. 그것은 '202d'로 나왔다. 그러나 이것은 일을 깨끗이합니다. 고맙습니다, 많이 감사드립니다. – andrewm921
@ user1205526 - 아 맞습니다. 'Character.getType()'은 실제로 BiDi 문자 유형이 아닌 일반 카테고리를 반환합니다. (메서드 이름이 싫다.)이 경우 일반 범주 16은 [FORMAT] (http://docs.oracle.com/javase/6/docs/api/java/lang/Character.html#FORMAT)이며 U + 202D (및 U + 202B)를 포함하여 꽤 많은 문자가 포함됩니다. –