java array loop

Solutions on MaxInterview for java array loop by the best coders in the world

showing results for - "java array loop"
Greta
11 Aug 2020
1		Scanner scanner = new Scanner( System.in );
2        int n = scanner.nextInt();
3        int[] a=new int[ n + 1 ];
4        for( int k = 1; k <= n; k ++ ){
5            a[ k ] = scanner.nextInt();
6        }
7        Arrays.sort( a );
8        for( int k = 1; k <= n; k ++ ){
9            System.out.print( a[k] + " " );
10        }
Imane
10 Jan 2018
1public class Test {
2    public static void main(String args[]) {
3        String string = args[0];
4        System.out.println("last character: " +
5                           string.substring(string.length() - 1)); 
6    }
7}
8