Video 26(ch6)

Yash
0

 





Program:-

public class ArrayV26 {
    public static void main(String []args){
        /* Suppose we have to store marks of 5 students we have two options:
        1. create 5 variables.
        2. use arrays (recommended)*/
        //there are three main ways to create an array.
        /*1. by separate declaration and memory allocation
        int [] Marks;
        Marks = new int[5];*/
        /*2.declaration and memory allocation at the same time.
        int [] Marks = new int[5];*/
        /*Declaring and initializing at the same time.
        int []Marks ={100.70,80.71,98}*/
        int []Marks = new int[5];
        Marks[0]=100;
        Marks[1]=70;
        Marks[2]=80;
        Marks[3]=71;
        Marks[4]=98;
        System.out.println(Marks[4]);
    }
}

Post a Comment

0 Comments
Post a Comment (0)
To Top