Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

how to add elements to an array in java dynamically

int[] nums = new int[5];
for(int i = 0; i < nums.length; i++){
  nums[i] = i + 2;
  System.out.println(nums[i]);
}
/*
  OUTPUT:
  2 3 4 5 6
  each time i is increased by 2
*/
Comment

PREVIOUS NEXT
Code Example
Java :: how to change image resolution in android programmatically 
Java :: java generate random id 
Java :: what language is android written in 
Java :: hashmap foreach 
Java :: java code samples 
Java :: len of number in java 
Java :: groovy ternary operator short form 
Java :: java selenium send keys numbers 
Java :: Java List Sort Using sort() method 
Java :: priority queue java comparator lambda 
Java :: jbutton set on action 
Java :: java check if enum contains value 
Java :: getting the last value of an integer in java 
Java :: kotlin variable in string 
Java :: Java Scanner nextLine() 
Java :: check whether a double is not a number in java 
Java :: java arraylist loop 
Java :: jframe in java 
Java :: java array to collection 
Java :: kmp java 
Java :: get input in java using joptionpane 
Java :: android list index 
Java :: java camel case 
Java :: iterate map in java 8 using stream 
Java :: java download 64-bit 
Java :: printing 2d array in java 
Java :: java copy file 
Java :: How to connect from Android emulator to application on localhost? 
Java :: does finally block executed after crash 
Java :: Getting Pending intent for 12 version 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =