Skip to main content

Featured Post

What is Salesforce ? Who is salesforce developer?

  1. Introduction to Salesforce Definition : Salesforce is the #1 Cloud-based CRM (Customer Relationship Management) platform that helps businesses manage relationships with customers, automate business processes, and analyze performance. Founded : 1999 by Marc Benioff. Type : SaaS (Software as a Service). Tagline : "No Software" – because everything runs on the cloud, without local installations. 2. Why Salesforce? Traditional CRMs were expensive and required servers, installations, and IT staff. Salesforce revolutionized CRM by moving everything to the cloud . Benefits: 🚀 Faster implementation ☁️ Cloud-based (accessible anywhere) 🔄 Customizable without coding (point-and-click tools) 🤝 Strong ecosystem & AppExchange (marketplace like Google Play for Salesforce apps) 🔐 Security & scalability 3. Salesforce Products & Cloud Offerings Salesforce is not just CRM; it has multiple clouds (modules) for different busine...

Array Concept in Java:-



It is a collection of elements of similar and dissimilar data type both.java provide integer array for similar type and Object array then dissimilar type element.


Type of Array:-

1.1) Single Dimension Array:-

using this array we can store element using rows. base index of single dimension array will be started from 0.


Datatype arrayname[] = new datatype[size];
int arr[] = new int[5];

Datatype [] arrayname = new Datatype[size];

int [] arr = new int[5];

Datatype arrayname[] = {value1,value2,value3,...}

int arr[] = {1,2,3,4,5}

Object arr[] = {"C","CPP",1003,12.34}


Program of Split one Array to two different Sub-Array?

class Splitarr
{
public static void main(String args[])
{
  System.out.println("array split program");
int arr[]= {2,11,34,56,67,78,89,91,12,11,12};

int size = arr.length;

int size1 = size/2;  //5
int size2 = size-size1;  //6

int arr1[] = new int[size1];
int arr2[] = new int[size2];

for(int i=0;i<arr.length;i++)  //4
{
    if(i<size1)
    {
      arr1[i]=arr[i];
      System.out.println("First"+arr1[i]);
    }
   else
    {
    arr2[i-size1]=  arr[i];
    System.out.println("Second"+arr2[i-size1]);
   }

}
}
}

/* program to sort the element of array in desc order */

class SortArr
{
   public static void main(String args[])
   {
      int arr[] = {1,23,11,67,87,96,32};
      int t;
      for(int i=0;i<arr.length;i++)
      {
          for(int j=i+1;j<arr.length;j++)
           {
                 if(arr[i]<arr[j])
                  {
                         t=arr[i];
                         arr[i]=arr[j];
                         arr[j]=t;
                     
                  }


           }
           System.out.println(arr[i]);

       }

    System.out.println(arr[1]);

   }


}

/* Program to find unique element in array */

class UArr
{
public static void main(String args[])
{
int arr[] = {1,1,4,5,8,4};
for(int i=0;i<arr.length;i++)  //1
{
     int c=0;
    for(int j=0;j<arr.length;j++)   // 0 to 5
     {
              if(arr[i]==arr[j] && i!=j)
                  c++;
      }
      if(c==0)
      System.out.println(arr[i]);
   
}

}
}









1.2) Multi Dimension Array:-

  Using this array we can store data using rows and columns. we can implement matrix operation, Datatable manipulation using MultiDimension Array.

Computer graphics also use a multidimensional array to draw the graphical component.

datatype arrayname[][] = new datatype[row][col];

datatype [][] arrayname = new datatype[row][col];

datatype arrayname[][] = {{value1,value2},{value1,value2}};

Q) WAP to InputData in MultiDimension Array and display into matrix form?


import java.util.Scanner;
class Matrix
{

   public static void main(String args[])
   {
       int row,column;
       Scanner sc = new Scanner(System.in);
       System.out.println("enter row");
       row=sc.nextInt();
       System.out.println("enter column");
       column=sc.nextInt();
       int arr[][] = new int[row][column];
       for(int i=0;i<row;i++)
       {
            for(int j=0;j<column;j++)
            {
              System.out.println("enter element for "+i+j+ " index");
              arr[i][j]=sc.nextInt();
            }

        }

       for(int i=0;i<row;i++)
       {
            for(int j=0;j<column;j++)
            {
              System.out.print(arr[i][j] +" ");
           
            }
            System.out.println();

        }
     
   


    }


}

//WAP to find max element in each row and complete matrix?

import java.util.Scanner;
class Matrix
{

   public static void main(String args[])
   {
       int row,column;
       Scanner sc = new Scanner(System.in);
       System.out.println("enter row");
       row=sc.nextInt();
       System.out.println("enter column");
       column=sc.nextInt();
       int arr[][] = new int[row][column];
       for(int i=0;i<row;i++)
       {
            for(int j=0;j<column;j++)
            {
              System.out.println("enter element for "+i+j+ " index");
              arr[i][j]=sc.nextInt();
            }

        } 

      int max1=0;
       for(int i=0;i<row;i++)
       {
            int max=0;
            for(int j=0;j<column;j++)
            {
              if(max<arr[i][j])
                max=arr[i][j];
              if(max1<arr[i][j])
                max1=arr[i][j];
              System.out.print(arr[i][j] +" ");
              
            }
            System.out.println("M:-"+max);

        } 
       System.out.println("Maximum of complete matrix"+max1);
       
     


    }



}




1.3) Jagged Array:-  Jagged Array is the collection of heterogeneous rows. means we can store a different number of column elements for each row.

datatype arrayname[][] = new datatype[row][];
arrayname[0] = new int[size];
...


Program to assign input and display output in Jagged Array?
Complete Program of Jagged Array:-

import java.util.Scanner;
class JaggedArr
{
     public static void main(String args[])
     {
        Scanner sc  = new Scanner(System.in);
        int r,c;
        System.out.println("enter row");
        r=sc.nextInt();
        int arr[][] = new int[r][];
        for(int i=0;i<r;i++)
        {
             System.out.println("enter column size");
             c=sc.nextInt();
             arr[i]=new int[c];
             for(int j=0;j<c;j++)
             {
                   System.out.println("enter row and column element for "+i

+j+" index ");
                   arr[i][j]=sc.nextInt();
              }

        }

       for(int i=0;i<r;i++)
        {
            for(int j=0;j<arr[i].length;j++)
            {
                  System.out.print(arr[i][j]+" ");
            }
            System.out.println(); 

       }


     }



}



1.4) Object Array:-  using this we can store dissimilar type of elements using the proper sequence.


1 PREDEFINE OBJECT CLASS ARRAY:-

Object arryname[] = {values,...}


2 User Define Object Array:-

Classname ref[] = new Classname[size];

Student arr[] = new Student[5];



Advantage of Array:-

1 we can store element using proper sequence hence we can easily search and sort element from an array.

2 array variable can store multiple values using a single identifier hence we can reduce extra program code to implement code.

3 Array reduce extra memory gap or allocation if we use normal variable.



Disadvantage:-

1 Array size is fixed means without size determination we can not create an array.

2 We can not add, append and delete an element of array dynamically.


(this limitation of the array has been solved by the collection framework in java.)



Q) WAP to Check Palindrome  using Char Array?

Logic
char arr[] = {'t','s','s','s','s','s','s','t'};

boolean flag=true;
for(int i=0;i<arr.length/2;i++)   0 t0 4
{
    if(arr[i]!=arr[(arr.length-1)-i])   arr[1]!=arr[3]
    {
      flag==false;
      System.out.println("not pallindrom");
      break;
   
    }

}

if(flag)
sout("palindrom");


Q) WAP to print reverse of Char Array?

Q) WAP to count total vowel and consonant in Char Array?

Q) WAP to  replace char array each char to next consecutive char?

Q) WAP to convert Char Array to upper case to lower case and lower case to Upper case



.................................................................................................................................................
Q) WAP to multiply two matrix ?

Q) WAP to find second max element in each row of matrix?

Q) WAP to count total prime element in matrix?

Q) WAP to find average of Matrix rows?

Q) WAP to sort matrix rows ?

............................................................................................................

Q) WAP to Find Max element in Jagged Array?

Q) WAP to sort row element of Jagged Array?

Q) WAP to reverse Jagged row element of Array?

Q) WAP to count total even and odd number in Jagged Array?












Comments

Popular posts from this blog

Conditional Statement in Python

It is used to solve condition-based problems using if and else block-level statement. it provides a separate block for  if statement, else statement, and elif statement . elif statement is similar to elseif statement of C, C++ and Java languages. Type of Conditional Statement:- 1) Simple if:- We can write a single if statement also in python, it will execute when the condition is true. for example, One real-world problem is here?? we want to display the salary of employees when the salary will be above 10000 otherwise not displayed. Syntax:- if(condition):    statements The solution to the above problem sal = int(input("Enter salary")) if sal>10000:     print("Salary is "+str(sal)) Q)  WAP to increase the salary of employees from 500 if entered salary will be less than 10000 otherwise the same salaries will be displayed. Solution:- x = int(input("enter salary")) if x<10000:     x=x+500 print(x)   Q) WAP to display th...

DSA in C# | Data Structure and Algorithm using C#

  DSA in C# |  Data Structure and Algorithm using C#: Lecture 1: Introduction to Data Structures and Algorithms (1 Hour) 1.1 What are Data Structures? Data Structures are ways to store and organize data so it can be used efficiently. Think of data structures as containers that hold data in a specific format. Types of Data Structures: Primitive Data Structures : These are basic structures built into the language. Example: int , float , char , bool in C#. Example : csharp int age = 25;  // 'age' stores an integer value. bool isStudent = true;  // 'isStudent' stores a boolean value. Non-Primitive Data Structures : These are more complex and are built using primitive types. They are divided into: Linear : Arrays, Lists, Queues, Stacks (data is arranged in a sequence). Non-Linear : Trees, Graphs (data is connected in more complex ways). Example : // Array is a simple linear data structure int[] number...

Top 50 Most Asked MERN Stack Interview Questions and Answers for 2025

 Top 50 Most Asked MERN Stack Interview Questions and Answers for 2025 Now a days most of the IT Company asked NODE JS Question mostly in interview. I am creating this article to provide help to all MERN Stack developer , who is in doubt that which type of question can be asked in MERN Stack  then they can learn from this article. I am Shiva Gautam,  I have 15 Years of experience in Multiple IT Technology, I am Founder of Shiva Concept Solution Best Programming Institute with 100% Job placement guarantee. for more information visit  Shiva Concept Solution 1. What is the MERN Stack? Answer : MERN Stack is a full-stack JavaScript framework using MongoDB (database), Express.js (backend framework), React (frontend library), and Node.js (server runtime). It’s popular for building fast, scalable web apps with one language—JavaScript. 2. What is MongoDB, and why use it in MERN? Answer : MongoDB is a NoSQL database that stores data in flexible, JSON-like documents. It...