Saturday, August 23, 2014

Java : Program to reversing a string


public class ReverseString {

/**
* @param args
*/
public static void main(String[] args) {

//String[] name = new String[10];
String name , rev = "";

Scanner in = new Scanner(System.in);
System.out.println("Enter the string for reversal :- ");
name = in.nextLine();

int len = name.length();

for(int i = len-1;i>=0;i--){
rev = rev + name.charAt(i);
}
System.out.println(rev);
}


}

Java : Program swapping two numbers without using third variable


public class SwapTwoNo {

/**
* @param args
*/
public static void swap(int a , int b){

a = b+a;
b = a-b;
a = a-b;

System.out.println("Values of a and b after swap := " + a +" "+ b + " respectively");
}


public static void main(String[] args) {

int a = 5;
int b = 6;
System.out.println("Values of a and b before swap := " + a +" "+ b + " respectively");
swap(a,b);

}
}

How to install Git ?

Steps to install GIT on your local system(Windows, Linux, Mac) Before installing Git to your machine, it's a good idea to check if it...