Example:
a = "xyaabbbccccdefww"
b = "xxxxyyyyabklmopq"
longest(a, b) -> "abcdefklmopqwxy"
a = "abcdefghijklmnopqrstuvwxyz"
longest(a, a) -> "abcdefghijklmnopqrstuvwxyz"
Best way to learn Java
a = "xyaabbbccccdefww"
b = "xxxxyyyyabklmopq"
longest(a, b) -> "abcdefklmopqwxy"
a = "abcdefghijklmnopqrstuvwxyz"
longest(a, a) -> "abcdefghijklmnopqrstuvwxyz"
The U.S. Census Bureau projects population based on the following assumptions:
One birth every 7 seconds
One death every 13 seconds
One new immigrant every 45 seconds
Write a program to display the population for each of the next five years. Assume the current population is 312,032,486 and one year has 365 days. Hint: In Java, if two integers perform division, the result is an integer. The fraction part is truncated.
For example, 5/ 4 is 1 (not 1.25) and 10 / 4 is 2 (not 2.5).
Also see our user generated FAQ on the wiki.
1. What is java.net?
java.net is a premier web-based, open community created to facilitate Java™ technology collaboration in applied areas of technology and industry solutions. java.net is a central gathering place for Java technology enthusiasts and existing communities across industries, platforms, and interest groups.
2. What is the goal of java.net?
The goal is to expand the Java™ technology portfolio of applications, tools, and services by promoting conversation and collaboration around development of practical applications across industry groups.
Continue reading………..
Write a program DisplayPattern2.java, which accepts a number as argument and print the following output:
Ex. Input : 5
Output:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
public class DisplayPattern2{public static void main(String args[]){int end = Integer.parseInt(args[0]);for(int i = 1; i <= end; i++){for(int j = 1; j <= i; j++)System.out.print(j + " ");System.out.println("");}}}
Output: 2 + 3 = 5
// Code NOT Tested !!
public class AdditionTest{public static void main(String[] args){int n1 = Integer.parseInt(args[0]);
int n2 = Integer.parseInt(args[1]);
String operator = args[2];if (operator.equals("*"))System.out.println(n1 + " * " + n2 + " = " + (n1 * n2));else if (operator.equals("+"))System.out.println(n1 + " + " + n2 + " = " + (n1 + n2));else if (operator.equals("-"))System.out.println(n1 + " - " + n2 + " = " + (n1 - n2));else
System.out.println(" Use a Correct Third Operator");
System.out.println(" Bye,");
}}
Blogger Labels: Java,Program,ArithmeticTest,arguments,Operator,Print
Write a program TestDemo.java which accepts the number as argument and print ” You Have Entered Zero ” if the Value is equal to 0. It should print “You have entered Positive value ” if the value is greater than 0. It should print “You have entered negative value ” if the Value is less than Zero.
Blogger Labels: Simple codes,Java,Program,argumentpublic class TestDemo{public static void main(String[] args){int n1 = Integer.parseInt(args[0]);
if(n1 == 0)
System.out.println("You have entered ZERO ");
else if (n1 < 0)System.out.println("You have entered Negetive value ");
else
System.out.println("You have entered positive value ");
}}