Exception in thread "main" java.lang.NegativeArraySizeException at Main.main(Main.java:21)

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] args) {
		 String  line   ; 
    String startTime ;
    String endTime;
    String name ;
     int n=0;
    int[] sumstrttime  = new int[n];
    int[] sumendtime = new int[n-1];
    int[] sum = new int[n];
    int time ;
    int hh;
    int mm;
    int endhh;
    int endmm;
    int meet ;
    StringTokenizer tokens = null;
    String fileName="C";
    try {   
 BufferedReader input = new BufferedReader(new FileReader(fileName) );
 while((line = input.readLine())!=null){
     System.out.println( line );
     StringTokenizer st = new StringTokenizer(  line ," ");
     int s = Integer.parseInt(System.console().readLine());

     if (n>9){
          startTime = tokens.nextToken();
     StringTokenizer start = new StringTokenizer(startTime ,":");
     hh=Integer.parseInt(start.nextToken());
     hh=hh*60;
     mm=Integer.parseInt(start.nextToken());
     
     System.out.println(startTime);
     endTime = tokens.nextToken();
     StringTokenizer end = new StringTokenizer(startTime ,":");
     endhh=Integer.parseInt(end.nextToken());
     endhh=endhh*60;
     endmm=Integer.parseInt(end.nextToken());
     name = tokens.nextToken();
     for(int i = 0; i < n; i++){
         sumstrttime  [i] = hh+mm;
         sumendtime[i] = endhh+endmm;
          sum[i]=sumendtime[i] - sumstrttime[i+1];
          System.out.print("time " + sum[i]);
     }
     
     }
     
  
   
 }
} 
catch(IOException e ){
    System.out.print("not found ");
}
	}
}


Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source