Answers for "how to define array in for loop java"

1

Java loop array

Scanner scanner = new Scanner( System.in );
        int n = scanner.nextInt();
        int[] a=new int[ n + 1 ];
        for( int k = 1; k <= n; k ++ ){
            a[ k ] = scanner.nextInt();
        }
        Arrays.sort( a );
        for( int k = 1; k <= n; k ++ ){
            System.out.print( a[k] + " " );
        }
Posted by: Guest on August-04-2021
1

java array loop

public class Test {
    public static void main(String args[]) {
        String string = args[0];
        System.out.println("last character: " +
                           string.substring(string.length() - 1)); 
    }
}
Posted by: Guest on October-15-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language