Architecture of Java Swing

raja
Updated on 24-Feb-2020 11:08:53

3K+ Views

Java Swing is a set of APIs that provides a graphical user interface (GUI) for the java programs. The Java Swing was developed based on earlier APIs called Abstract Windows Toolkit (AWT). The Java Swing provides richer and more sophisticated GUI components than AWT. The GUI components are ranging from a simple level to complex tree and table. The Java Swing provides the pluggable look and feels to allow look and feel of Java programs independent from the underlying platform.Features of Java SwingThe Java Swing is platform independent and follows the MVC (Model View and Controller) framework.Pluggable look and feel − The Java ... Read More

Difference Between Static and Shared Libraries

Mahesh Parahar
Updated on 24-Feb-2020 11:03:30

3K+ Views

In programming context library is something which has some sort of that code which is pre compiled and could get reused in any program for some specific functionality or feature.Now on the basis of execution and storage of this code library is classified in two types i.e Static library and Shared library.Following are the important differences between Static library and Shared library.Sr. No.KeyStatic libraryShared library1DefinitionStatic library is the library in which all the code to execute the file is in one executable file and this file get copied into a target application by a compiler, linker, or binder, producing an ... Read More

Check Whether Element is in Array in Java

Ali
Ali
Updated on 24-Feb-2020 10:55:45

156 Views

Following example uses Contains method to search a String in the Array.Exampleimport java.util.ArrayList; public class Main {    public static void main(String[] args) {    ArrayList objArray = new ArrayList();    ArrayList objArray2 = new ArrayList();    objArray2.add(0, "common1"); objArray2.add(1, "common2");   objArray2.add(2, "notcommon"); objArray2.add(3, "notcommon1");    objArray.add(0, "common1"); objArray.add(1, "common2");    System.out.println("Array elements of array1"+objArray);    System.out.println("Array elements of array2"+objArray2);    System.out.println("Array 1 contains String common2?? " +objArray.contains("common1"));    System.out.println("Array 2 contains Array1?? " +objArray2.contains(objArray) );     }  }OutputThe above code sample will produce the following result.Array elements of array1[common1, common2] Array elements of array2[common1, common2, notcommon, notcommon1] Array ... Read More

Difference Between REST API and SOAP API

Mahesh Parahar
Updated on 24-Feb-2020 10:45:49

13K+ Views

As we know that each machine understand and deals in its different language or input so web-services are something which are required for inter communication between machines and to exchange data between them. In order to implement some set of restrictions over their communication some set of rules and regulations are defined which are known as web-services which basically defines the format and type of data that need to be exchanged and specifically a contract which both machines should be aware of before taking part in communication.This communication system can be categorized into two types, namely Simple Object Access Protocol ... Read More

Find the Dimensions of a 2D Array in Java

Rahul Sharma
Updated on 24-Feb-2020 10:44:41

521 Views

Following example helps to determine the upper bound of a two dimensional array with the use of arrayname.length.https://www.tutorialspoint.com/javaexamples/arrays_upperbound.htm

Create Subarray from Another Array in Java

Kumar Varma
Updated on 24-Feb-2020 10:42:51

18K+ Views

Use Arrays.copyOfRange() method to get a subarray.Exampleimport java.util.Arrays; public class Tester {    public static void main(String[] args) {       int[] array = new int[] {1, 2, 3, 4, 5};       int[] subArray = Arrays.copyOfRange(array, 0, 2);       System.out.println("Array: ");       for(int i = 0; i < array.length; i++) {          System.out.print(array[i] + " ");       }       System.out.println("Sub array: ");       for(int i = 0; i < subArray.length; i++) {          System.out.print(subArray[i] + " ");       }    } }OutputArray: 1 2 3 4 5 Sub array: 1 2

Removal of Negative Numbers from an Array in Java

Rama Giri
Updated on 24-Feb-2020 10:41:59

811 Views

Following program shows how to remove negative numbers from an array.Exampleimport java.util.ArrayList; import java.util.Iterator; import java.util.List; public class Tester {    public static void main(String[] args) {       List objArray = new ArrayList();       objArray.clear();       objArray.add(2);       objArray.add(-3);       objArray.add(4);       System.out.println("Array before removing an element "+objArray);       Iterator iterator = objArray.iterator();                while(iterator.hasNext()) {          Integer next = iterator.next();          if(next < 0) {             iterator.remove();          }       }       System.out.println("Array after removing an element"+objArray);    } }OutputArray before removing an element [ 2, -3, 4 ] Array after removing an element [ 2, 4 ]

Declare an Object Array in Java

Arjun Thakur
Updated on 24-Feb-2020 10:41:06

317 Views

Array of Object class can be created which can accept any type of object. During operation on such array, instanceof operator can be used.Examplepublic class Tester {    public static void main(String[] args) {       Object[] dataArray = new Object[3];       dataArray[0] = new Integer(0);       dataArray[1] = new String("1");       dataArray[2] = new Boolean(false);       for(Object data: dataArray) {          if(data instanceof Integer) {             System.out.println(((Integer) data).intValue());          }          if(data instanceof String) {             System.out.println(data);          }          if(data instanceof Boolean) {             System.out.println(((Boolean) data).booleanValue());          }       }    } }Output0 1 false

Convert Vector to String Array in Java

Fendadis John
Updated on 24-Feb-2020 10:40:14

406 Views

Following program converts a vector into a array of String.Exampleimport java.util.Vector; public class Tester {    public static void main(String[] args) {       Vector data = new Vector();       data.add("A");       data.add("B");       data.add("C");       String[] strObjects = data.toArray(new String[data.size()]);       for(String obj: strObjects) {          System.out.println(obj);       }    } }

Find the Sum of All Numbers in a Java Array

Arushi
Updated on 24-Feb-2020 10:38:11

229 Views

Following program print the sum of the all the numbers in an array.Examplepublic class Tester {    public static void main(String[] args) {       int[] dataArray = {1, 2, 3, 4};       int sum = 0;       for(int i: dataArray) {          sum += i;       }       System.out.println(sum);    } }Output10

Advertisements