Hi to all!!!! I Am Arpit Vijay Vergiya.
On this Blog i tried to share about Java.
I hope this blog will help you to learn many new things in java.
Keep visiting!!!
Keep sharing

by · No comments:

Swastik pattern using java




import java.util.Scanner;
class Swastik{
		
		public static void main(String args[])
		{
				Scanner sc = new Scanner(System.in);
				System.out.println("Enter number");
				int num = sc.nextInt();
				for(int i=1;i<=num;i++)
				{
						for(int j=1;j<=num;j++)
						{
								if((j==1 && i<=num/2) || (j==num/2) || (i==num/2)||(i==1 && j>=num/2) || ((i==num/2 || j==num) && i>num/2) || (i==num && j<=num/2))
								{
										System.out.print("*");
								}
								else
									System.out.print(" ");
						}
						System.out.println();
				}
		}
}




Read More
by · No comments:

Matrix multiplication


import java.util.Scanner;
class MatrixMul{
		public static void main(String args[])
		{
				int a[][]= new int[3][3];
				int b[][]= new int[3][3];
				int c[][]=new int[3][3];
				int i,j,k;
				
				Scanner sc = new Scanner(System.in);
				System.out.println("enter Element 9 of 1st String");
				for(i=0;i<3;i++)
				{
						for(j=0;j<3;j++)
						{
								a[i][j]=sc.nextInt();
						}
				}
				
				System.out.println("enter Element 9 of 2nd String");
				for(i=0;i<3;i++)
				{
						for(j=0;j<3;j++)
						{
								b[i][j]=sc.nextInt();
						}
				}
				
				System.out.println("Matrix A\tMatrix B");
				for(i=0;i<3;i++)
				{
						for(j=0;j<3;j++)
						{
								System.out.print(a[i][j]+" ");
						}
						
						System.out.print("\t\t");
						
						for(k=0;k<3;k++)
						{
								System.out.print(b[i][k]+" ");
						}
						System.out.println();
				}
				
				//logic for multiply
				
				int mul=0;
				for(i=0;i<3;i++)
				{
						for(j=0;j<3;j++)
						{
								
								for(k=0;k<3;k++)
								{
										mul+= a[i][j]*b[j][k];
								}
								
								c[i][j]=mul;
								mul=0;
						}
			
				}
				
				System.out.println("Result is:");
				for( i=0;i<3;i++)
				{
						for(j=0;j<3;j++)
						{
								System.out.print(c[i][j]+" ");
						}
						
						System.out.println(" ");
				}
				
		}
}

Read More
by · No comments:

Arrange String character wise

import java.util.Scanner;
class StringCharSort{
		
		public static void main(String args[])
		{
				Scanner sc = new Scanner(System.in);
				System.out.println("Enter a String:");
				String str = sc.nextLine();
				char ch[] = str.toCharArray();
				for(int i=0;i	for(int j=1;j
						{
								if(ch[j-1]>ch[j])
								{
										char temp = ch[j-1];
										ch[j-1]=ch[j];
										ch[j]=temp;
								}
						
						}
						
				}
				for(char c :ch)
							{
									System.out.print(c);
							}
				
		}
		
}


Read More
by · No comments:

How to check given String is palindrom or not in java

String is palindrom or not


import java.util.Scanner;
class StringPalindrom{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    System.out.println("Enter a line");
    String str = sc.nextLine();
    String str1="";
    char ch[] = str.toCharArray();
    for(int i=ch.length-1;i>=0;i--)
    {
      str1+=ch[i];
    }
     if(str.equals(str1))
      System.out.println("Palindrom");
     else
      System.out.println("Not palindrom");
    
    
  }
}






Read More