string in java


public class StringDemoExample {
public static void main(String[] args) {
String s1 = “nag”;
String s2 = “nag”;
String s3 = s1;
String s4 = new String(“nag”);
String s5 = new String(“nag”);
System.out.println(s1 == s2);
System.out.println(s1 == s3);
System.out.println(s1.equals(s3));
System.out.println(s1 == s4);
System.out.println(s1.equals(s4));
System.out.println(s4 == s5);
System.out.println(s4.equals(s5));
}
}

What is the output of the about example?

sample programs for java beginners


import java.util.Scanner;
public class Demo{
public static void main(String args[]){
int a, b, c, d;
System.out.println(“Enter range of numbers to print their multiplication table”);
Scanner in = new Scanner(System.in);
a = in.nextInt();
b = in.nextInt();
for (c = a; c <= b; c++) {
System.out.println(“Multiplication table of “+c);
for (d = 1; d <= 10; d++) {
System.out.println(c+”*”+d+” = “+(c*d));
}
}
}
}

sample programs for java beginners


import java.util.Scanner;
public class MultiplyTableDemo{
public static void main(String args[]){
int n, c;
System.out.println(“Enter an integer “);
Scanner in = new Scanner(System.in);
n = in.nextInt();
System.out.println(“Multiplication table of “+n+” is :”);
for ( c = 1 ; c <= 10 ; c++ )
System.out.println(n+”*”+c+” = “+(n*c));
}
}

test your skill?

give comments