Skip to main content

Posts

Showing posts with the label Take an array of names as input from the user and print them on the screen

Arrays Introduction | Java Complete Placement Course | Lecture 10

Java - Introduction to Programming Lecture 10 Arrays In Java Arrays in Java are like a list of elements of the same type i.e. a list of integers, a list of booleans etc.  Creating an Array (method 1) - with new keyword int [] marks = new int [ 3 ] ; marks[ 0 ] = 97 ; marks[ 1 ] = 98 ; marks[ 2 ] = 95 ; Creating an Array (method 2) int [] marks = { 98 , 97 , 95 } ; Taking an array as an input and printing its elements. import java . util .*;   public class Arrays {     public static void main ( String args []) {         Scanner sc = new Scanner ( System . in );         int size = sc . nextInt ();         int numbers [] = new int [ size ];           for ( int i = 0 ; i < size ; i ++) {             numbers [ i ] = sc . nextInt ();    ...