TG Telegram Group Link
Channel: Advance Java πŸ‘¨β€πŸ’»
Back to Bottom
58. Merge two array.

class MergeArrayDemo
{
public static void main(String args[])
{
Integer a[]={1,2,3,4};
Integer b[]={5,6,7,0};
Integer[] both = concat(a, b);

System.out.print("\nFirst Array : ");
for(int i=0;i<a.length;i++)
{
System.out.print(a[i]+"\t");
}

System.out.print("\nSecond Array : ");
for(int i=0;i<b.length;i++)
{
System.out.print(b[i]+"\t");
}

System.out.print("\nMerged Array : ");
for(int i=0;i<both.length;i++)
{
System.out.print(both[i]+"\t");
}
}

public static Integer[] concat(Integer[] a, Integer[] b)
{
int aLen = a.length;
int bLen = b.length;
Integer[] c= new Integer[aLen+bLen];
System.arraycopy(a, 0, c, 0, aLen);
System.arraycopy(b, 0, c, aLen, bLen);
return c;
}
}

@java_codings
59. Middle value of an array.

import java.util.*;

class MiddleValue
{
public static void main(String args[])
{
int[] a;
int i, j, n, sum = 0, swap, size;

double t;
Scanner sc = new Scanner(System.in);

System.out.println("Enter size of array");
size = sc.nextInt();

a = new int[size];

System.out.println("Enter numbers ");
for (i = 0; i < size; i++)
{
a[i] = sc.nextInt();
}

System.out.println("Numbers are : ");
for (i = 0; i < size; i++)
{
System.out.print(a[i] + " ");
}

//Sorting
for (i = 0; i < (size - 1); i++)
{
for (j = 0; j < (size - i - 1); j++)
{
if (a[j] > a[j + 1])
{
swap = a[j];
a[j] = a[j + 1];
a[j + 1] = swap;
}
}
}

System.out.println("\nNumbers in sorted order : ");
for (i = 0; i < size; i++)
{
System.out.print(a[i] + " ");
}

//Finding the Middle Value
if (size % 2 == 0)
{
n = (size + 1) / 2;
t = (a[n] + a[n - 1]) / 2.0;
System.out.println("\nMiddle Value is : " + t);
}

else
{
System.out.println("\nMiddle Value is : " + a[size / 2]);
}

}
}

@java_codings
60. Mirror Matrix.

import java.util.*;

class MirrorMatrix
{
public static void main(String[] args)
{
int row, column;
Scanner in = new Scanner(System.in);

System.out.print("Enter number of rows for matrix :");
row = in.nextInt();
System.out.print("Enter number of rows for matrix :");
column = in.nextInt();

int matrix[][] = new int[row][column];

System.out.println("Enter matrix : ");

for (int i = 0; i < row; i++)
{
for (int j = 0; j < column; j++)
{
matrix[i][j] = in.nextInt();
}
}

System.out.println("Mirror matrix : ");

for (int i = 0; i < row; i++)
{
for (int j = column - 1; j >= 0; j--)
{
System.out.print(matrix[i][j] + "\t");
}

System.out.println("");
}
}
}

@java_codings
61. Missing number in an array.

class MissingNumberArray
{
public static int count = 0;
public static int position = 0;
public static boolean flag = false;

public static void main(String[] args)
{
int a[] = {0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18, 20, 21, 23};

findMissingNumbers(a, position);
}

private static void findMissingNumbers(int a[], int position)
{
if (position == a.length - 1)
return;

for (; position < a[a.length - 1]; position++)
{
if ((a[position] - count) != position)
{
System.out.println("Missing Number: " + (position + count));
flag = true;
count++;
break;
}
}

if (flag)
{
flag = false;
findMissingNumbers(a, position);
}
}
}

@java_codings
62. Multidimensional Array.

class MultiDimArrayExample
{
public static void main(String[] args)
{
String[][] names = {{"Mr. ", "Mrs. ", "Ms. "}, {"Smith", "Jones"}};
// Mr. Smith
System.out.println(names[0][0] + names[1][0]);
// Ms. Jones
System.out.println(names[0][2] + names[1][1]);
}
}

@java_codings
https://youtube.com/@codingfragments?si=g21jjjTZ1T07VWXX

Check out this YouTube channel to learn the programming language.
Advance Java πŸ‘¨β€πŸ’» pinned Β«https://youtube.com/@codingfragments?si=g21jjjTZ1T07VWXX Check out this YouTube channel to learn the programming language.Β»
Advance Java πŸ‘¨β€πŸ’» pinned Β«Javascript Tutorial: https://www.youtube.com/watch?v=wm6LNo6715o&list=PLcGjb_nf4rNwdtG7JP0j0qcgAZ74b4-5AΒ»
Advance Java πŸ‘¨β€πŸ’» pinned Β«Node js tutorial: https://www.youtube.com/watch?v=XkpbjI_GyJo&list=PLcGjb_nf4rNxR1eCFakb_-4TUA4FCOW9qΒ»
Advance Java πŸ‘¨β€πŸ’» pinned Β«Webscraping of flipkart product using node js with practical example. https://youtu.be/_Q0EMB1McXE Please like, share and subscribeΒ»
Learn the basics of reacjs and setup themes from scratch.
https://youtube.com/playlist?list=PLcGjb_nf4rNw89854fHsqHTeCpLaNgoEw&si=J90lPx8hFLHlqRmM

You will learn in this series.
1. How to set up the project theme
2. Best practices and tips for folder structure in ReactJS
3. Basics of React
4. How to create a reusable component and reuse it in a project.
5. How to create a theme layout
6. State and Props (pass data between components)
HTML Embed Code:
2024/04/25 11:27:32
Back to Top