Wednesday, 17 May 2017

How Add Method Works In ArrayList In Java With The Help Of Example

An ArrayList is an object that is used to store a group of the other objects and allows us to do manipulation on these objects one by one. Java ArrayList class basically uses a dynamic array for storing the elements.
The basic features of Java ArrayList class are given below:
  1. Java ArrayList class can contain duplicate elements to store.
  2. Java ArrayList class maintains insertion order.
  3. In Java ArrayList class, the manipulation is slow because there is lot of shifting to be occurred if any element is removed from the array list from any index.Suppose there is an arraylist of 4 elements having indices 0,1,2,3. If we want to delete the element placed at the index no, 1, then there will be shifting of elements from down as all the remaining elements goes up covering all the indices, so this is the reason the manipulation in arraylist is slow. 
  4. Java ArrayList class is non synchronized.It mean that there can be case when there can be multiple threads that can work together to modify the list at same time.

Friday, 12 May 2017

Registration form using swings in java

Registration form in java:

In this tutorial you will learn how to make a registration form in java using swings. Swings basically are used to develop desktop based applications for the users. Swings helps in creating beautiful applications that are rich and good enough to represent. With the help of Swings you can easily create attractive desktop based applications. JFrame is a class which is a extended version of java.awt.Frame which support Swings component architecture.

Following are the constructors that can be used to create applications:

1 .JFrame():Constructs a new frame that is initially invisible to the user.

2 JFrame(String title):Creates a new, initially invisible Frame to the user with the specified given title.
3 JFrame(String title, GraphicsConfiguration gc): It will create a JFrame with the specified title and the specified or configured GraphicsConfiguration of a screen device or monitor.


Wednesday, 10 May 2017

Program to sum two dimensional array in java

Sum of two dimensional array:-

This program will explain how to add array which is two dimensional.You first have to know what is two dimensional array.

Two Dimensional Array- Two dimensional array those array which is consists of elements of 2-d type. Basically 2-d means rows and columns.2-d dimensional array. It's syntax can be declared as given below:

data_type array_name[size1][size2];

A way to initialize the two dimensional array at the time of declaration is given below:

int arr[4][3]={{1,2,3}, {2,3,4}, {3,4,5}, {4,5,6}};
Example to declare 2-d dimensional array is:

int m[][]=new int[4][6];

Tuesday, 9 May 2017

Creating Progress Bar Using JProgressBar

Creating Progress Bar Using JProgressBar:

In this tutorial you will learning how to create Progressbar using JProgressBar for java application that is basically swings application.

A progress bar is basically a widget(an application, or a component of an interface, that enables a user to perform a function or can help to access a service) that displays progress of a lengthy task, usually used for downloading a or transfer some files. For creating a progress bar in swings you have to use the JProgressBar class. With the help of JProgressBar, you can easily create vertical or horizontal progress bar according to your need. In addition to the JProgressBar class,it allows you to create another kind of progress bar which is known as indeterminate progress bar. The indeterminate progress bar is used to display progress with unknown progress or the progress cannot express by the percentage.Basically it does not explain about how the progress is remain in terms of percentage.

There are some constructors used to create ProgressBar. These are:

1. public JProgressBar()- It creates a Horizontal progress bar.
2. public JProgressBar(int orientation)- It helps in creating horizontal as well as vertical progress bar. You can also create progress bar in any orientation.
3. public JProgressBar(int minimum,int maximum)- It help in creating progress bar which is having minimum values and maximum values.

Saturday, 6 May 2017

Servlets Tutorial for Beginners

Introduction to SERVLETS:

  1. A servlet is a Java class that extends an application hosted on a web server.
  2. Servlet technology is used to create web application 
  3. Servlet Handles the HTTP request-response process.
  4. Often it thought of as an applet that runs on a server.
  5. Provides a component base architecture for web development, using the Java Platform
  6. Servlet technology is a technology which is robust and scalable only because of java language.
Java Servlets are basicallly the programs that run on a Web or Application server and act as a middle layer between a request coming from a Web browser or others HTTP clients and databases or applications on the HTTP servers.
With the help of Servlets, you can easily collect input from the users through web page forms, present records from the database or any another source, and can create dynamic web pages.


Friday, 5 May 2017

Hibernate Overview for Beginners

Hibernate Overview:

Hibernate is an Object-Relational Mapping(ORM) solution for JAVA. It is an open source framework created by Gavin King in 2001. It is a powerful, high performance Object-Relational Persistence and Query service for any Java Application.
Hibernate maps Java classes to database tables and from Java data types to SQL data types and relieves the developer lots of  programming tasks. Hibernate acts between traditional Java objects and database server to handle all the works in persisting those objects based on the appropriate O/R mechanisms and patterns.

Hibernate Advantages:
  1. Hibernate takes care of mapping Java classes to database tables using XML files and without writing any line of code.
  2.  Provides simple APIs for storing and retrieving the Java objects directly to and from database.
  3.  If there is change in the database or in any table, then you only need to change the XML file properties.
  4.  Abstracts away the unfamiliar SQL types and provides a way to work around familiar Java Objects.
  5.  Hibernate does not require an application server to operate on.
  6.  Manipulates Complex associations of objects of your database.
  7.  Minimizes database access with smart fetching strategies.
  8.  Provides simple querying of data.
  9. No need to self create tables.
  10. It creates tables in database according to needs.

Supported Databases:
Hibernate supports almost all the major RDBMS. Following is a list of few of the database engines supported by Hibernate:
  1.  HSQL Database Engine
  2.  Oracle
  3.  Microsoft SQL Server Database
  4.  Sybase SQL Server
  5.  Informix Dynamic Server
  6.  DB2/NT
  7.  MySQL
  8.  PostgreSQL
  9.  FrontBase

Manipulation usings Swings in java

Data Manipulation Using Swings in java:-

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class database extends JFrame implements ActionListener
{
Connection con;
Statement st;
ResultSet rs;
JLabel l3=new JLabel("Select id");
JLabel l=new JLabel("Emp id");
JLabel l1=new JLabel("Name");
JLabel l2= new JLabel("Department");
JComboBox c=new JComboBox();
JTextField t=new JTextField();
JTextField t1=new JTextField();
JTextField t2=new JTextField();
JButton b=new JButton("Insert");
JButton b1=new JButton("Delete");
JButton b2=new JButton("Update");
JButton b3=new JButton("Select");
JButton b4=new JButton("Clear");

Thursday, 4 May 2017

Working of Tomcat Server

Tomcat Working:-

Working of Tomcat Server Tomcat:-
Tomcat is a servlet container. It implements only the servlets and jsp specification.
Tomcat makes use of Sun Microsystems specific specifications.
Tomcat, developed by Apache (www.apache.org), is a standard reference implementation for Java servlets and JSP. It can be used standalone as a Web server or be plugged into a Web server

1. Installation:-

You can download Tomcat from

http://tomcat.apache.org/download-60.cgi

Before running the servlet, you need to start the Tomcat servlet engine. To start Tomcat, you have to first set the JAVA_HOME environment variable to the JDK home directory.

By default, Tomcat runs on part 8080. You can change it to a different port.

Customer Bill Information in java

Program Of Customer Bill Information:

package package1;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class array5 extends Applet implements ActionListener
{
int i,p,q,r;
  Label lab=new Label("CUSTOMER BILL INFORMATION");
Label l1=new Label("NAME");
Label l2=new Label("PRODUCT CODE");
Label l3=new Label("PRODUCT CATEGORY");
Label l4=new Label("PRICE");
Label l5=new Label("QUANTITY");
TextField t1=new TextField();
TextField t2=new TextField();
TextField t3=new TextField();
Choice ch1=new Choice();
Choice ch2=new Choice();
List ls=new List();
Button b=new Button("BILL");
public void init()
{

Sum of Array Matirx in java

Printing Sum of array matrix using Scanner class:-

import java.util.Scanner;
public class arr_sum_matrix 
{
public static void main(String[] args) 
{
Scanner sc=new Scanner(System.in);
int a[]=new int[50];
int b[]=new int[50];
int c[]=new int[100];
int y,n;
System.out.println("ENTER FIRST SIZE OF YOUR ARRAY");
n=sc.nextInt();
for(y=0;y<n;y++)
{
a[y]=sc.nextInt();

Printing array values in java

How to Print array values:-

public class arr_console
{
public static void main(String[] args) 
{
int i;
String[] name=new String[4];
name[0]="MY NAME";
name[1]="IS";
name[2]="BALWANT";
name[3]="SINGH";
for(i=0;i<name.length;i++)
{
System.out.println(name[i]);
}
}
}
As mentioned above we have created an array with length 4.
It will store four String values.And there is use of for loop to retrieve all the values of array.

ActionListener Implementation in Swings

How to Implement ActionListener  in java:-

import java.applet.Applet;
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
public class action_lis extends Applet implements ActionListener
{
Button b=new Button("CHECKED IT OUT");
Button b1=new Button("PRINT");
public void init()
{
this.setLayout(null);
b.setBounds(300,300,120,70);
b1.setBounds(500,300,120,70);
add(b);
add(b1);
b.addActionListener(this);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent ar)
{
if(ar.getSource()==b)
{
JOptionPane.showMessageDialog(null,"MY NAME IS BALWANT");
}
if(ar.getSource()==b1)
{
JOptionPane.showMessageDialog(null,"YOU HAVE BEEN PRINTING 100 PAGES");
}
}
}
Basically actionlistener is used  to trigger a particular event.
In this program i have created two buttons named as b and b1. Button b is named as CHECKED IT OUT and Button b1 named as PRINT . On clicking Button b it will open an dialog box which will show "MY NAME IS BALWANT".  On clicking Button b1 it will open an dialog box which will show  "YOU HAVE BEEN PRINTING 100 PAGES".

OUTPUT:

First it will show as given below:

How-to-implement-ActionListener-in-Swings-in-java

When You click CHECKED IT OUT it will show as given below:

How-to-implement-ActionListener-in-Swings-in-java


When you will click PRINT it will show as given below:

How-to-implement-ActionListener-in-Swings-in-java

You can check this link for how to do manipulation using swings.



Also you can check how to make Registration Form using Swings in java:


https://wingsofm.blogspot.in/2017/05/registration-form-using-swings-in-java.html

Monday, 1 May 2017

Github Tutorial for Beginners

GITHUB INTRODUCTION:

 Github is a web-based Git or version control repository.GitHub offers both plans for private and free repositories on the same account which are commonly used to host open-source software projects.With the help of GitHub you can easily create your own repository in your local system, then you can push all your code to web server repository which is provided by GitHub.
You can create private repository as well as public repository.
Private repository is a paid repository and public repository is free.
You can choose anyone.

Git can be easily installed locally on your system. You can easily download git for your pc from the link given below.

Oracle / PLSQL: FOR LOOP

set serveroutput on; declare a1 varchar2(100); begin select count(*) into a1 from employees; for i in 1..a1 loop dbms_output.put_line...