CSES - Aalto Competitive Programming 2024 - wk1 - Mon - Results
Submission details
Task:Backpacking
Sender:Sakari
Submission time:2024-09-02 16:43:05 +0300
Language:Java
Status:COMPILE ERROR

Compiler report

input/test.java:7: error: no suitable method found for split(no arguments)
        String[] arrS = c.split();
                         ^
    method String.split(String,int) is not applicable
      (actual and formal argument lists differ in length)
    method String.split(String) is not applicable
      (actual and formal argument lists differ in length)
1 error

Code

public class test{

    public static void main( String args[]){
        int x1 = 0;
        String c = System.console().readLine();
        String[] arrS = c.split();
        for (String x : arrS){
            int a = Integer.parseInt(x);
            x1 += a;
        }
        System.out.println(x1);
    }
}