welcome-file-list in web.xml file of Project

by Chaitanya Singh April 14, 2014

Have you ever seenĀ <welcome-file-list> tag in your web.xml file and wondering what it is? In this post we will discuss what is this tag and why we use it. The tagĀ <welcome-file-list> is used for specifying the files that needs to be invoked by server by default, if you do not specify a file name while loading the project on browser. […]

Read the full article →

GenericServlet class

by Chaitanya Singh April 14, 2014

GenericServlet class defines a protocol-independent(HTTP-less) servlet. However while building a website or an online application, you may want to have Http protocol, in that case extend HttpServlet instead of GenericServlet class. Read more about HTTP protocol basics here. This is the blue print of GenericServlet class: public abstract class GenericServlet extends java.lang.Object implements Servlet, ServletConfig, java.io.Serializable As you can see […]

Read the full article →

Servlet Interface

by Chaitanya Singh April 13, 2014

The Servlet interface defines the methods that must be implemented by all the servlets. In short, all servlet must implement Servlet interface directly or indirectly (To implement this interface, you can write a generic servlet that extends javax.servlet.GenericServlet or an HTTP servlet that extends javax.servlet.http.HttpServlet). A servlet is a java program that receives the request from client(web browser) and returns […]

Read the full article →

Java program for linear search – Example

by Chaitanya Singh April 9, 2014

Example Program: This program uses linear search algorithm to find out a number among all other numbers entered by user. /* Program: Linear Search Example * Written by: Chaitanya from beginnersbook.com * Input: Number of elements, element's values, value to be searched * Output:Position of the number input by user among other numbers*/ import java.util.Scanner; class LinearSearchExample { public static […]

Read the full article →

Java program to print Floyd’s triangle – Example

by Chaitanya Singh April 5, 2014

Example Program: This program will prompt user for number of rows and based on the input, it would print the Floyd’s triangle having the same number of rows. /* Program: It Prints Floyd's triangle based on user inputs * Written by: Chaitanya from beginnersbook.com * Input: Number of rows * output: floyd's triangle*/ import java.util.Scanner; class FloydTriangleExample { public static […]

Read the full article →

Java Program to check Even or Odd number

by Chaitanya Singh February 11, 2014

import java.util.Scanner; class CheckEvenOdd { public static void main(String args[]) { int num; System.out.println("Enter an Integer number:"); //The input provided by user is stored in num Scanner input = new Scanner(System.in); num = input.nextInt(); /* If number is divisible by 2 then it's an even number * else odd number*/ if ( num % 2 == 0 ) System.out.println("Entered number […]

Read the full article →

Java Program to display first n or first 100 prime numbers

by Chaitanya Singh January 20, 2014

Program to display first n prime numbers import java.util.Scanner; class PrimeNumberDemo { public static void main(String args[]) { int n; int status = 1; int num = 3; //For capturing the value of n Scanner scanner = new Scanner(System.in); System.out.println("Enter the value of n:"); //The entered value is stored in the var n n = scanner.nextInt(); if (n >= 1) […]

Read the full article →

Java program to display prime numbers from 1 to 100 and 1 to n

by Chaitanya Singh January 20, 2014

Program to display the prime numbers from 1 to 100 It will display the prime numbers between 1 and 100. class PrimeNumbers { public static void main (String[] args) { int i =0; int num =0; //Empty String String primeNumbers = ""; for (i = 1; i <= 100; i++) { int counter=0; for(num =i; num>=1; num--) { if(i%num==0) { […]

Read the full article →

Java program to check prime number

by Chaitanya Singh January 18, 2014

This program will prompt user to enter a number and then it will check and display whether the input number is prime or not. import java.util.Scanner; class PrimeCheck { public static void main(String args[]) { int temp; boolean isPrime=true; Scanner scan= new Scanner(System.in); System.out.println("Enter a number for check:"); //capture the input in an integer int num=scan.nextInt(); for(int i=2;i<=num/2;i++) { temp=num%i; […]

Read the full article →

java program to check palindrome string using recursion

by Chaitanya Singh January 18, 2014

Program: Check whether String is palindrome using recursion package beginnersbook.com; import java.util.Scanner; class PalindromeCheck { //My Method to check public static boolean isPal(String s) { // if length is 0 or 1 then String is palindrome if(s.length() == 0 || s.length() == 1) return true; if(s.charAt(0) == s.charAt(s.length()-1)) /* check for first and last char of String: * if they […]

Read the full article →

java program to check palindrome string using Stack, Queue, for or while loop

by Chaitanya Singh January 18, 2014

In this tutorial we will see programs to check whether the given String is Palindrome or not. Following are the ways to do it. 1) Using Stack 2) Using Queue 3) Using for/while loop Program 1: Palindrome check Using Stack import java.util.Stack; import java.util.Scanner; class PalindromeTest { public static void main(String[] args) { System.out.print("Enter any string:"); Scanner in=new Scanner(System.in); String […]

Read the full article →

Our Friend's website link : FromDev.com