Posts

Showing posts from July, 2018

Update a value on specific index in Array List | Programming Hub 0

Update a value on specific index in Array List in Java Code: package labno1; import java.util.ArrayList; import java.util.Scanner; public class ArraylistSearch {     public static void main(String[] args) {                    Scanner n = new Scanner(System.in);          ArrayList<String> obj = new ArrayList<String>();          System.out.println("Enter length of Array list");          int elem;          elem = n.nextInt();           System.out.println("Enter ArrayList values");          for (int i = 0; i < elem; i++) {              obj.add(n.next());     ...

Search an Element in Arraylist in java | Programming Hub

Array List In java Code: package labno1; import java.util.ArrayList; import java.util.Scanner; public class ArraylistSearch {      public static void main(String[] args) {         Scanner n = new Scanner(System.in);          ArrayList<String> obj = new ArrayList<String>();          System.out.println("Enter length of Array list");          int elem;          elem = n.nextInt();           System.out.println("Enter Array values");          for (int i = 0; i < elem; i++) {              obj.add(n.next());           }      String k;    ...

GUI in Java | How to make userdefined login page in graphical user interface in java

Image
 Login page in graphical user interface (GUI) in java Code: package javaapplication22; import javax.swing.*; public class JavaApplication22 {     public static void main(String[] args) {                  JFrame frame = new JFrame("My First Swing Example");                frame.setSize(350, 200);         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);         JPanel panel = new JPanel();            frame.add(panel);         frame.setVisible(true);     }         JLabel userLabel = new JLabel("User");         userLabel.setBounds(10,20,80,25);         p...

Multiple Inheritence in Java /How to inherit a class from another in Java| Programmer Hub

Image
Multiple Inheritence in Java I nheritance allows to reuse classes by deriving a new class from an existing one . The existing class is called the parent class, or super class , or base class . The derived class is called the child class or subclass or derived class .   The child inherits characteristics of the parent(i.e the child class inherits the methods and data defined for the parent class). Code: package inhert; class Animal{     String color="Brown";     String weight="55 kg";   } class Dog extends Animal{     void display(){         String color=super.color;    String weight=super.weight;         System.out.println("Color of Dog is " +color);         System.out.println("Weight of Dog is "+weight);     }  } public class Inhert { public static void main(String[] args) {  ...

Difference between the Java and C language and C ++ language

How is Java different from C …    C Language Major difference is that C is a structure oriented language and   Java is an object oriented language and has mechanism to define classes and objects.   Java does not support pointer type . Java does not have preprocessor , so we cant use #define, #include and #ifdef statements.   Java does not include structures, unions and enum data types.   Java does not include keywords like goto, sizeof and type def.   Java adds labeled break and continue statements.   Java adds many features required for object oriented programming.   How is Java different from C++ …   C++ language   Features removed in java: Java doesn’t support pointers to avoid unauthorized access  of memory locations .   Java does not include structures, unions and Enum data   types.   Java does not support operator over loading .   Pre-processor plays less important role in ...