-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayLength.java
More file actions
24 lines (23 loc) · 819 Bytes
/
ArrayLength.java
File metadata and controls
24 lines (23 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//to find the length of an array:
import java.io.*;
//import java.util.Scanner;
public class ArrayLength
{
public static void main(String args[]) throws IOException
{
InputStreamReader obj=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(obj);
//Scanner key=new Scanner(System.in);
//int n=key.nextInt();
System.out.println("enter size of array:");
int n=Integer.parseInt(br.readLine());
int arr[]=new int[n];
System.out.println("enter array elements:");
for(int i=0;i<n;i++)
{
arr[i]=Integer.parseInt(br.readLine());
}
int length=arr.length; // "arrayname.length" is syntax to find length of an array.
System.out.println("length of array="+length);
}
}