Wednesday 28 October 2015

Java Tutorial : Java Conditional-Or Operator


Click here to watch in Youtube :
https://www.youtube.com/watch?v=eGEQxhe4OB0&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java Tutorial : Java Conditional-Or Operator 
Java Tutorial : Java Conditional-Or Operator 

ConditionalOrOperatorDemo.java
class ConditionalOrOperatorDemo
{
    public static void main(String[] args)
    {
        int value1 = 1;
        int value2 = 2;

        /*
         * true || true is true
         * 
         * 1 || 1 is 1
         */
        
        boolean value = (value1 == 1) || (value2 == 2);
        System.out.println(value);

        /*
         * true || false is true
         * 
         * 1 || 0 is 1
         */
        
        value = (value1 == 1) || (value2 == 90);
        
        System.out.println(value);

        /*
         * false || true is true
         * 
         * 0 || 1 is 1
         */
        value = (value1 == 20) || (value2 == 2);
        System.out.println(value);

        /*
         * false || false is false
         * 
         * 0 || 0 is 0
         */
        value = (value1 == 100) || (value2 == 90);
        System.out.println(value);

    }
}
Output
true
true
true
false
To Download OperatorsDemoConditional-Or-App Project Click the below link
https://sites.google.com/site/javaee4321/java/OperatorsDemoConditional-Or-App.zip?attredirects=0&d=1

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Tuesday 27 October 2015

    Java Tutorial : Java Conditional-And Operator


    Click here to watch in Youtube :
    https://www.youtube.com/watch?v=WlrJ4ywU6_s&list=UUhwKlOVR041tngjerWxVccw

    Click the below Image to Enlarge
    Java Tutorial : Java Conditional-And Operator
    Java Tutorial : Java Conditional-And Operator
    ConditionalAndOperatorDemo.java
    class ConditionalAndOperatorDemo
    {
        public static void main(String[] args)
        {
            int value1 = 1;
            int value2 = 2;
    
            /*
             * true && true is true
             * 
             * 1 && 1 is 1
             */
            System.out.println((value1 == 1) && (value2 == 2));
    
            /*
             * true && false is false
             * 
             * 1 && 0 is 0
             */
            System.out.println((value1 == 1) && (value2 == 90));
    
            /*
             * false && true is false
             * 
             * 0 && 1 is 0
             */
            System.out.println((value1 == 20) && (value2 == 2));
    
            /*
             * false && false is false
             * 
             * 0 && 0 is 0
             */
            System.out.println((value1 == 100) && (value2 == 90));
    
        }
    }
    
    Output
    true
    false
    false
    false
    
    To Download OperatorsDemoConditionalAndApp Project Click the below link
    https://sites.google.com/site/javaee4321/java/OperatorsDemoConditionalAndApp.zip?attredirects=0&d=1

    See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Java Tutorial : Java Prefix and Postfix Operators


    Click here to watch in Youtube : 
    https://www.youtube.com/watch?v=h8d6uV15bYU&list=UUhwKlOVR041tngjerWxVccw

    PrePostDemo1.java
    class PrePostDemo1
    {
        public static void main(String[] args)
        {
            int i = 5;
            i++;
            // prints 6
            System.out.println(i);
            ++i;
            // prints 7
            System.out.println(i);
            
        }
    }
    
    Output
    6
    7
    
    PrePostDemo2.java
    class PrePostDemo2
    {
        public static void main(String[] args)
        {
            int i = 5;
    
            int j = ++i;
    
            System.out.println("j : " + j);
    
            System.out.println("i : " + i);
    
        }
    }
    
    Output
    j : 6
    i : 6
    
    PrePostDemo3.java
    class PrePostDemo3
    {
        public static void main(String[] args)
        {
            int i = 5;
    
            int j = i++;
    
            System.out.println("j : " + j);
    
            System.out.println("i : " + i);
    
        }
    }
    
    Output
    j : 5
    i : 6
    
    To Download OperatorsDemoPrePostFixApp Project Click the below link
    https://sites.google.com/site/javaee4321/java/OperatorsDemoPrePostFixApp.zip?attredirects=0&d=1

    See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Java Tutorial : Java Operators - Playlist

    Java Tutorial : Java Unary Operators


    Click here to watch in Youtube :
    https://www.youtube.com/watch?v=qLAFniod4wo&list=UUhwKlOVR041tngjerWxVccw

    Click the below Image to Enlarge
    Java Tutorial : Java Unary Operators
    UnaryOperatorDemo.java
    class UnaryOperatorDemo
    {
    
        public static void main(String[] args)
        {
    
            int unaryPlusValue = +1;
            System.out.println("unaryPlusValue : " + unaryPlusValue);
    
            int k = 90;
    
            int unaryMinusValue = -k;
    
            System.out.println("unaryMinusValue : " + unaryMinusValue);
    
            int i = 1;
    
            System.out.println("Before incrementing, value of i : " + i);
    
            i++;
    
            System.out.println("After incrementing, value of i : : " + i);
    
            int j = 6;
    
            System.out.println("Before decrementing, value of j : " + j);
    
            j--;
    
            System.out.println("After decrementing, value of j : " + j);
    
            boolean success = false;
            // false
            System.out.println(success);
            // true
            System.out.println(!success);
    
        }
    }
    
    Output
    unaryPlusValue : 1
    unaryMinusValue : -90
    Before incrementing, value of i : 1
    After incrementing, value of i : : 2
    Before decrementing, value of j : 6
    After decrementing, value of j : 5
    false
    true
    
    To Download OperatorsDemoUnaryApp Project Click the below link
    https://sites.google.com/site/javaee4321/java/OperatorsDemoUnaryApp.zip?attredirects=0&d=1

    See also:

  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Java Tutorial : Java Arithmetic Operators


    Click here to watch in Youtube :
    https://www.youtube.com/watch?v=SRtVvkFGXaA&list=UUhwKlOVR041tngjerWxVccw

    Click the below Image to Enlarge
    Java Tutorial : Java Arithmetic Operators 
    ArithmeticDemo.java
    class ArithmeticDemo
    {
    
        public static void main(String[] args)
        {
    
            int addedValue = 1 + 2;
            System.out.println("1 + 2 = " + addedValue);
    
            int subtractedValue = 2 - 1;
            System.out.println("2 - 1 = " + subtractedValue);
    
            int multipliedValue = 2 * 2;
            System.out.println("2 * 2 = " + multipliedValue);
    
            int diviedValue = 4 / 2;
            System.out.println("4 / 2 = " + diviedValue);
    
            int remainderValue = 5 % 2;
            System.out.println("5 % 2 = " + remainderValue);
            
            String firstString = "Hi";
            String secondString = " Welcome John.";
            String thirdString = firstString+secondString;
            System.out.println(thirdString);
            
    
        }
    }
    
    Output
    1 + 2 = 3
    2 - 1 = 1
    2 * 2 = 4
    4 / 2 = 2
    5 % 2 = 1
    Hi Welcome John.
    
    To Download OperatorsDemoArithmeticApp Project Click the below link
    https://sites.google.com/site/javaee4321/java/OperatorsDemoArithmeticApp.zip?attredirects=0&d=1

    See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Java Tutorial : Java Operators


    Click here to watch in Youtube :
    https://www.youtube.com/watch?v=Dd2j-OGWlZQ&list=UUhwKlOVR041tngjerWxVccw

    Click the below Image to Enlarge
    Java Tutorial : Java Operators
    Java Tutorial : Java Operators
    Java Tutorial : Java Operators
    See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Java Tutorial : Java Array (Advantages and Disadvantages)


    Click here to watch in Youtube :
    https://www.youtube.com/watch?v=BALT8TFctG0&list=UUhwKlOVR041tngjerWxVccw

    Click the below Image to Enlarge
    Java Tutorial : Java Array (Advantages and Disadvantages) 
    Java Tutorial : Java Array (Advantages and Disadvantages) 

    See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Java Tutorial : Java Array (Add two Matrices)


    Click here to watch in Youtube : 
    https://www.youtube.com/watch?v=cs6GhaUVRoc&list=UUhwKlOVR041tngjerWxVccw

    ArrayDemo.java
    /*
     * Addition of 2 matrices in java.
     */
    
    class ArrayDemo
    {
        public static void main(String[] args)
        {
            /*
             * Creating two matrices.
             */
            int a[][] =
            {
            { 1, 2, 3 },
            { 4, 5, 6 } };
    
            int b[][] =
            {
            { 1, 2, 3 },
            { 4, 5, 6 } };
    
            /*
             * Creating another matrix to store the sum of two matrices
             */
            int c[][] = new int[2][3];
    
            /*
             * Adding and printing addition of 2 matrices
             */
            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    c[i][j] = a[i][j] + b[i][j];
                    System.out.print(c[i][j] + " ");
                }
                System.out.println();
            }
    
        }
    
    }
    
    Output
    2 4 6 
    8 10 12
    
    To Download ArrayDemoAddMatricesApp Project Click the below link
    https://sites.google.com/site/javaee4321/java/ArrayDemoAddMatricesApp.zip?attredirects=0&d=1

    See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Java Tutorial : Java Array (Name of the Array Object)


    Click here to watch in Youtube :
    https://www.youtube.com/watch?v=7nUQTFnrT10&list=UUhwKlOVR041tngjerWxVccw

    ArrayDemo.java
    /*
     * In java, array is an object. For array object, an proxy class is created 
     * whose name can be obtained by getClass().getName() method on the object.
     */
    
    class ArrayDemo
    {
        public static void main(String[] args)
        {
            int[] intArray = new int[5];// declaration and instantiation
    
            intArray[0] = 110;// initialization
            intArray[1] = 220;
            intArray[2] = 750;
    
            Class<? extends int[]> classObject = intArray.getClass();
            String name = classObject.getName();
    
            System.out.println("name : " + name);
    
        }
    
    }
    
    Output
    name : [I
    
    To Download ArrayDemoGetNameApp Project Click the below link
    https://sites.google.com/site/javaee4321/java/ArrayDemoGetNameApp.zip?attredirects=0&d=1

    See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Java Tutorial : Java Array (Types Of Array)


    Click here to watch in Youtube :
    https://www.youtube.com/watch?v=eSRhNZnZ7vw&list=UUhwKlOVR041tngjerWxVccw

    Click the below Image to Enlarge
    Java Tutorial : Java Array (Types Of Array) 
    Java Tutorial : Java Array (Types Of Array) 
    Java Tutorial : Java Array (Types Of Array) 
    SingleDimensionalArrayDemo1.java
    class SingleDimensionalArrayDemo1
    {
        public static void main(String[] args)
        {
            int[] intArray = new int[5];// declaration and instantiation
    
            intArray[0] = 110;// initialization
            intArray[1] = 220;
            intArray[2] = 750;
            intArray[3] = 130;
            intArray[4] = 150;
    
            for (int i = 0; i < intArray.length; i++)
            {
                System.out.println("Element at index position " + i + " : " + intArray[i]);
            }
        }
    
    }
    
    Output
    Element at index position 0 : 110
    Element at index position 1 : 220
    Element at index position 2 : 750
    Element at index position 3 : 130
    Element at index position 4 : 150
    
    SingleDimensionalArrayDemo2.java
    public class SingleDimensionalArrayDemo2
    {
    
        public static void main(String[] args)
        {
            int intArray[] =
            { 51, 61, 89 };// declaration, instantiation and initialization
    
            for (int i = 0; i < intArray.length; i++)
            {
                System.out.println("Element at index position " + i + " : "
                        + intArray[i]);
            }
        }
    
    }
    
    Output
    Element at index position 0 : 51
    Element at index position 1 : 61
    Element at index position 2 : 89
    
    MultidimensionalArrayDemo1.java
    public class MultidimensionalArrayDemo1
    {
    
        public static void main(String[] args)
        {
            int[][] intArray = new int[2][3];// 2 rows and 3 columns
    
            intArray[0][0] = 1;
            intArray[0][1] = 2;
            intArray[0][2] = 3;
            intArray[1][0] = 4;
            intArray[1][1] = 5;
            intArray[1][2] = 6;
            
            int rows = intArray.length;
    
            for (int i = 0; i < rows; i++)
            {
                int columns = intArray[i].length;
    
                System.out.println("Number of columns in row " + i + " is : "
                        + columns);
    
                for (int j = 0; j < columns; j++)
                {
                    System.out.println("Element at " + "intArray[" + i + "]" + "["
                            + j + "] : " + intArray[i][j]);
    
                }
                System.out.println();
            }
    
        }
    
    }
    
    Output
    Number of columns in row 0 is : 3
    Element at intArray[0][0] : 1
    Element at intArray[0][1] : 2
    Element at intArray[0][2] : 3
    
    Number of columns in row 1 is : 3
    Element at intArray[1][0] : 4
    Element at intArray[1][1] : 5
    Element at intArray[1][2] : 6
    
    MultidimensionalArrayDemo2.java
    public class MultidimensionalArrayDemo2
    {
        public static void main(String[] args)
        {
            /*
             * declare, instantiate, initialize
             */
            int[][] intArray =
            {
            { 1, 2, 3 },
            { 4, 5, 6 } };// 2 rows and 3 columns
    
            int rows = intArray.length;
    
            for (int i = 0; i < rows; i++)
            {
                int columns = intArray[i].length;
    
                System.out.println("Number of columns in row " + i + " is : "
                        + columns);
    
                for (int j = 0; j < columns; j++)
                {
                    System.out.println("Element at " + "intArray[" + i + "]" + "["
                            + j + "] : " + intArray[i][j]);
    
                }
                System.out.println();
            }
    
        }
    }
    
    Output
    Number of columns in row 0 is : 3
    Element at intArray[0][0] : 1
    Element at intArray[0][1] : 2
    Element at intArray[0][2] : 3
    
    Number of columns in row 1 is : 3
    Element at intArray[1][0] : 4
    Element at intArray[1][1] : 5
    Element at intArray[1][2] : 6
    
    To Download ArrayDemoJavaArrayTypesApp Project Click the below link
    https://sites.google.com/site/javaee4321/java/ArrayDemoJavaArrayTypesApp.zip?attredirects=0&d=1

    See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Java Tutorial : Java Array (Java Array Pass to Method)


    Click here to watch in Youtube :
    https://www.youtube.com/watch?v=ZvNr3KfSv1g&list=UUhwKlOVR041tngjerWxVccw

    ArrayDemo.java
    /*
     * We can pass the java array to method so that we can reuse the same logic on any array.
     */
    
    class ArrayDemo
    {
        public static void main(String[] args)
        {
            int[] intArray1 = new int[5];// declaration and instantiation
    
            intArray1[0] = 110;// initialization
            intArray1[1] = 220;
            intArray1[2] = 750;
            intArray1[3] = 130;
            intArray1[4] = 150;
    
            System.out.print("Max value in intArray1 :");
            max(intArray1);
            
            
            int[] intArray2 = new int[3];// declaration and instantiation
    
            intArray2[0] = 45;// initialization
            intArray2[1] = 50;
            intArray2[2] = 10;
            
            System.out.print("Max value in intArray2 :");
            max(intArray2);
            
        }
    
        private static void max(int[] intArray)
        {
            int max = intArray[0];
            for (int i = 0; i < intArray.length; i++)
            {
                if (max < intArray[i])
                {
                    max = intArray[i];
                }
            }
            System.out.println(max);
        }
    
    }
    
    Output
    Max value in intArray1 :750
    Max value in intArray2 :50
    
    To Download ArrayDemoPassToMethodApp Project Click the below link
    https://sites.google.com/site/javaee4321/java/ArrayDemoPassToMethodApp.zip?attredirects=0&d=1

    See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Java Tutorial : Java Array (Multidimensional Array - String Create and Intialize)


    Click here to watch in Youtube :
    https://www.youtube.com/watch?v=TqS4S2d0tr4&list=UUhwKlOVR041tngjerWxVccw

    Click the below Image to Enlarge
    Java Tutorial : Java Array (Multidimensional Array - String Create and Intialize)
    ArrayDemo.java
    class ArrayDemo
    {
        public static void main(String[] args)
        {
    
            String[][] strArray =
            {
            { "Ram", "Peter" },
            { "Apple", "Ball" },
            { "Bike", "Car" } };
    
            System.out.println("Element at strArray[0][0] : " + strArray[0][0]);
            System.out.println("Element at strArray[0][1] : " + strArray[0][1]);
    
            System.out.println();
    
            System.out.println("Element at strArray[1][0] : " + strArray[1][0]);
            System.out.println("Element at strArray[1][1] : " + strArray[1][1]);
    
            System.out.println();
    
            System.out.println("Element at strArray[2][0] : " + strArray[2][0]);
            System.out.println("Element at strArray[2][1] : " + strArray[2][1]);
    
        }
    }
    
    Output
    Element at strArray[0][0] : Ram
    Element at strArray[0][1] : Peter
    
    Element at strArray[1][0] : Apple
    Element at strArray[1][1] : Ball
    
    Element at strArray[2][0] : Bike
    Element at strArray[2][1] : Car
    
    ArrayLoopDemo.java
    public class ArrayLoopDemo
    {
    
        public static void main(String[] args)
        {
            String[][] strArray =
                {
                { "Ram", "Peter" },
                { "Apple", "Ball" },
                { "Bike", "Car" } };
            
            int rows = strArray.length;
    
            System.out.println("Number of rows : " + rows+"\n");
            
            for (int i = 0; i < rows; i++)
            {
                int columns = strArray[i].length;
                
                System.out.println("Number of columns in row "+ i +" is : " + columns);
                
                for (int j = 0; j < columns; j++)
                {
                    System.out.println("Element at " + "strArray[" + i + "]" + "["
                            + j + "] : " + strArray[i][j]);
    
                }
                System.out.println();
            }
    
        }
    
    }
    
    Output
    Number of rows : 3
    
    Number of columns in row 0 is : 2
    Element at strArray[0][0] : Ram
    Element at strArray[0][1] : Peter
    
    Number of columns in row 1 is : 2
    Element at strArray[1][0] : Apple
    Element at strArray[1][1] : Ball
    
    Number of columns in row 2 is : 2
    Element at strArray[2][0] : Bike
    Element at strArray[2][1] : Car
    
    To Download ArrayDemoMultiDimensionalStrCreateAndInitializeApp Project Click the below link
    https://sites.google.com/site/javaee4321/java/ArrayDemoMultiDimensionalStrCreateAndInitializeApp.zip?attredirects=0&d=1

    See also:

  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial