여기에 또 다른 기본적인 질문이 있습니다. 마지막 질문을 따르고 있습니다. 나는이 질문들이 매우 기본 적이기 때문에 아무도 괴롭히지 않기를 바란다. 먼저 이름을 입력으로 가져 와서 정수로 변경 한 다음 합계를 계산하여이 합계가 작동하지 않는 방정식에 넣어야합니다.왜 합계가 작동하지 않습니까?
시간을내어 도와 주셔서 감사합니다.
package loveindex;
import java.util.Scanner;
import java.lang.Math;
public class LoveIndex {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Testing Scanner, write something: ");
String testi = scan.nextLine();
testi = testi.toUpperCase();
char[] ascii1 = testi.toCharArray();
for(char ch:ascii1){
// System.out.println((int)ch+" ");
int[] a = {(int)ch};
int all = IntStream.of(a).sum(); // >>> here it shows an error and the quick fix as always is just a bigger mess ...
System.out.println("The sum is " + a);
}
System.out.println("Testing Scanner, write something: ");
String testi2 = scan.nextLine();
testi2 = testi2.toUpperCase();
char[] ascii2 = testi2.toCharArray();
for(char ch:ascii2){
System.out.println((int)ch+" ");
}
scan.close();
}
}
을 받고 어떤 오류? – WannaBeCoder
자바 8을 사용하고 있습니까? – WannaBeCoder
내가 코드에 대해 이미 언급 한 부분은 구문에 대한 오류를 표시 한 다음 빠른 수정을 사용하여 클래스를 만든 다음 구문 "OF"의 다른 부분에 대한 오류를 보여줍니다. –