Saturday, 2 December 2017

How to use auto refresh using java jsp program code

Learning Java Programming Made Easy




<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@ page import="java.io.*,java.util.*;" %>
<html>
<body>
<%
   response.setIntHeader("Refresh", 1);
   Calendar calendar = new GregorianCalendar();

   String am_pm;
   int hour = calendar.get(Calendar.HOUR);
   int minute = calendar.get(Calendar.MINUTE);
   int second = calendar.get(Calendar.SECOND);
   if(calendar.get(Calendar.AM_PM) == 0)
      am_pm = "AM";
   else
      am_pm = "PM";
   String CT = hour+":"+ minute +":"+ second +" "+ am_pm;
   out.println( CT + "\n");
%>
</body>
</html>

How to use if loop in java programming

Learning Java Programming Made Easy



import java.io.*
import java.util.*

public class ifloop
{
public static void main(String args[])
{
int x;
Scanner sc=new Scanner(System.in);
System.out.println("Enter 1 or 2");
x=sc.nextInt();
if(x==1)
{
System.out.println("Well Done...! You Entered x="+x);
}
elseif(x==2)
{
System.out.println("Congrats...! You Entered x="+x);
}
else
{
System.out.println("Sorry...! Invalid Numbar");
}
}
}

How to use for loop in java program

Learning Java Programming Made Easy


import java.io.*;
import java.util.*;

public class forloop
{
public static void main(String args[])
{
int x,y;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the maximum count");
y=sc.nextInt();
for(x=0;x<y;x++)
{
System.out.println("x="+x);
}
}
}

How to use Do-While loop in java

Learning Java Programming Made Easy

import java.io.*;
import java.util.*;

public class do_while
{
public static void main(String args[])
{
int x=0;
do
{
x=x+1;
System.out.println("x="+x);
}
while(x!=10);
}
}

Tuesday, 28 February 2017

How to use java code for type casting

//********************************Start**************************

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package javaapplication1;

/**
 *
 * @author HP
 */
public class Java_Type_Casting {
 public static void main(String args[])
    {

        byte b;
        int i = 257;
        double d = 323.142;

        System.out.println("Conversion of int to byte.");
        b = (byte) i;
        System.out.println("i is " + i + " and b is " + b);

        System.out.println("\nConversion of double to int.");
        i = (int) d;
        System.out.println("d is " + d + " and i is " + i);

        System.out.println("\nConversion of double to byte.");
        b = (byte) d;
        System.out.println("d is " + d + " and b is " + b);

    }
}

//********************************End***************************

How to use Java Code for Login Form design

//*****************************Start************************

import java.awt.*;
import javax.swing.*;
/**
 *
 * @author HP
 */
public class AWT_Login_From {
    JFrame f;
    JPanel jp;
    JLabel heading,username,password,forgetpass;
    JTextField tuser;
    JPasswordField pass;
    JButton login,reset;

    public AWT_Login_From()
    {
        f=new JFrame("Login Form");
        f.setSize(400,300);
        f.setVisible(true);
        f.setLocation(500, 250);
        f.setResizable(false);
        jp=new JPanel();
        jp.setLayout(null);
        f.add(jp);


        heading=new JLabel("Login Form");
        heading.setBounds(150, 20, 150, 50);
        jp.add(heading);

        username=new JLabel("USER NAME");
        username.setBounds(60, 100, 80, 10);
        jp.add(username);

        password=new JLabel("PASSWORD");
        password.setBounds(60, 150, 80, 10);
        jp.add(password);

        forgetpass=new JLabel("Forget Password");
        forgetpass.setBounds(210, 170, 100, 10);
        jp.add(forgetpass);

        tuser=new JTextField("");
        tuser.setBounds(140,95,170,25);
        jp.add(tuser);

        pass=new JPasswordField();
        pass.setBounds(140,145,170,25);
        jp.add(pass);

        login=new JButton("Login");
        login.setBounds(60,205,100,25);
        jp.add(login);

        reset=new JButton("Reset");
        reset.setBounds(240,205,100,25);
        jp.add(reset);

     
    }
public static void main(String args[])
    {
    AWT_Login_From lf=new AWT_Login_From();


}
}


//*****************************End*************************

How to use Java Code to Print 1 to 45 In Triangle Shape...

//*************************Start**************************

public class Print_1_TO_45_In_Triangle
{
    public static void main(String args[])
    {
        int n=1, i, j;
        for(i=0; i<10; i++)
        {
            for(j=0; j<i; j++)
            {
                if(0<n&&n<10)
                {
                   System.out.print("0");
                }

                System.out.print(n + "  ");
                n++;
            }
            System.out.println();
        }
    }
}


//*************************ENd**************************

How to use Java for ShutDown Computer From using Code

//******************Start**************************

import java.io.*;

/**
 *
 * @author HP
 */
public class Shut_Down_Computer {
public static void main(String args[]) throws IOException
    {
        Runtime runtime = Runtime.getRuntime();
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        System.out.print("Enter No. of Seconds after which You want your Computer to Shutdown :");
        long a=Long.parseLong(br.readLine());

        Process proc = runtime.exec("shutdown -s -t " +a);

        System.exit(0);
    }
}


//******************End***************************

How to use Java Code Example for Try-Catch Function to Get Exception Error

//**************************Start***************************

import java.util.*;

/**
 *
 * @author HP
 */
public class try_catch {

    public static void main(String args[]) {
        int i, j;
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter any 2 no.");
        i = sc.nextInt();
        j = sc.nextInt();
        try {
            int result = i / j;
            System.out.println("Result= " + result);
        }

        catch (Exception es) {
            System.err.println(es.getMessage());
        }
    }
}


//**************************End***************************

Tuesday, 14 February 2017

How to use java code for grid program


#  Grid Demo Program



//***********************Start********************

import java.awt.*;
public class grid extends Frame {

    Button b1, b2, b3, b4,b5,b6;
    public grid() {
        setLayout(new GridLayout(3,2,5,5));
        b1 = new Button("b1");
        b2 = new Button("b2");
        b3 = new Button("b3");
        b4 = new Button("b4");
        b5 = new Button("b5");
        b6 = new Button("b6");
     
        add(b1);
        add(b2);
        add(b3);
        add(b4);
        add(b5);
        add(b6);

pack();
 setVisible(true);
   
    }
    public static void main(String arsg[]) {
        grid obj = new grid();
    }
 
}
//*************************End*****************************

Charactor_At_Position

public class Char_At_Position { public static void main(String[] args) { String str = "Wankhede"; String rev=""...