Skip to content

Latest commit

 

History

History
122 lines (89 loc) · 4.15 KB

README.md

File metadata and controls

122 lines (89 loc) · 4.15 KB

JavaArrays

Fixed number of values of same data type. Syntax: datatype nameOfVariable[] = new dataType[size];

  1. int[] arr = new int[size];
  2. int []arr = new int[size];
  3. int arr[] = new int[size];

Indexing & Properties:

  1. Indexing :

int arr[] = new int[5]; => Indexes are always start from 0; => ith index = arr[i]

Access first and last elements: arr[0] & arr[n-1]

Note: There are not heterogeneous arrays in java.

  1. Properties:

  1. int arr[] = new int[5]; Ex: System.out.print(arr.length); //5

  2. By default all the elements are initialized with 0;

Ex:

  1. for(int i=0; i< arr.length; i++){ System.out.println(arr[i]); } output: 0 0 0 0 0

  2. float arr[] = new float[5]; for(float i=0; i< arr.length; i++){ System.out.println(arr[i]); } output: 1.0 2.0 3.0 4.0 5.0

  3. double arr[] = new double[5]; for(double i=0; i< arr.length; i++){ System.out.println(arr[i]); } output: 1.0 2.0 3.0 4.0 5.0

Note: Java cannot have negative indexing as it will throw error.

sumofStatic1DArray image

Sum of 1D Array elements with user input image

Min And Max in 1D Array image

Frequency Of X in 1D Array image

Reverse A 1D array image

Product Of Elements In 1D Array image

Copy The 1D Array into Output Array image

EvenAndOddElementsInOneDArray image

TemperatureDifferenceInOneDArray image

AverageRainFallInOneDArray image

CountOfElementsGreaterThanB image

PositionOfElementB image

InsertThatElementin1DArray image

RemoveThatElementin1DArray image

ReverseArrayToGetNewArray image

SwappingOfTwoElements In One Dimension Array image

ReverseAPartOfArray In One Dimension Array image

FrequencyOfElements In One Dimension Array image

OddNegativeIncrement In Dynamic Array image

Max Occurrence of character in a String image

Sum of [Max-Min] of Each 1D Array from a 2D Array image

Max Product Pair in 1D Array image