हिंदी

Using array elements

Advertisements

Topics

CISCE: Class 10

Assigning Data in a 1 D Array:

  1. By using the assignment statement: The data values are defined within the program itself. It may be an integer, a String, a char or a float type. For Example: int m[ ] = {15,7,22,12,34,45,23,31,27,40}; 
  2. By using the BlueJ System: In this method, the data values are to be entered at the time of execution of the program. Here  the array is declared, but the values are entered during execution by the user. Syntax: public static void main(int m[ ])
  3. By using the lnputStreamReader class: The data values are to be entered at the time of executing the program. It may be any primitive datatype. Syntax: int m[ ]= new int[IO] ;  it creates locations in the memory to store 10 different integer numbers.  
  4. By using Scanner Class: Import “java.util.*”, create “Scanner” object, then declare “int arr[] = new int[5];”.

Related QuestionsVIEW ALL [15]

Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×