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
by · No comments:

Differences Between C , C++, and Java

Differences Between C , C++, and Java

Table Comparing C, C++ and Java:

This table is a summary of the differences found in the article.
Feature
C
C++
Java
Programming Approach
Procedural Programming Language
Procedural, OOP, Generic Programming languages
OOP, Generic Programming languages.
Compiled Source Code
Executable in  Native Code
Executable in Native Code
Compiled into Java byte code
Memory management
Manual Done,
Manual Done,
Managed, using a garbage collector
Pointers
Yes, very commonly used.
Yes, very commonly used, but some form of references available too.
No pointers; references are used instead.
Preprocessor
Yes
Yes
No
String Type
Character arrays
Character arrays, objects
Objects
Complex Data Types
Structures, unions
Structures, unions, classes
Classes
Inheritance
N/A
Multiple class inheritance
Single class inheritance, multiple interface implementation
Operator Overloading
N/A
Yes
No
Automatic coercions
(Conversion)
Yes, with warnings if loss could occur
Yes, with warnings if loss could occur
Not at all if loss could occur; must cast explicitly
Variadic Parameters
Yes
Yes
No
Goto Statement
Yes
Yes
No

 

Read More