Java String Concatenation Operators / Chapter -3 /Operator & Assignments



java string


 Java String Concatenation Operator




  1. This (+) is the only overloaded operator in java.Sometimes it acts as "Arithmetic operators" and Sometimes it acts as "String Concatenation Operators".

  2. If both arguments are number type then it acts as "Arithmetic Addition Operator".

  3. If at least one argument is String type then (+)operators act as "String Concatenation Operators".



example 1:-
String a="javabychetan";
int b=10,c=20,d=30;
System.out.println(a+b+c+d);        o/p is              javabychetan102030
System.out.println(b+c+d+a);       o/p is               60javabychetan
System.out.println(b+c+a+d);       o/p is               30javabychetan30
System.out.println(b+a+c+d);       o/p is               10javabychetan2030

  •   explanation of the first System.out.println(a+b+c+d);






java string

javabychetan.com



Java - String Concatenation Operators / Chapter -3 /Operator & Assignments

javabychetan.blogspot.com

  1. This (+) is the only overloaded operator in java.Sometimes it acts as "Arithmetic operators" and Sometimes it acts as "String Concatenation Operators".
  2. If both arguments are number  type then it acts as "Arithmetic Addition Operator".
  3. If at least one argument is String type then (+)operators act as "String Concatenation Operators".
example 1:-
                String a="javabychetan";
                int b=10,c=20,d=30;
               System.out.println(a+b+c+d);        o/p is              javabychetan102030
               System.out.println(b+c+d+a);       o/p is               60javabychetan
               System.out.println(b+c+a+d);       o/p is               30javabychetan30
               System.out.println(b+a+c+d);       o/p is               10javabychetan2030
       
  •                explanation of the first System.out.println(a+b+c+d);
           
javabychetan.blogspot.com

Java - Arithmetic Operators / Chapter -2 /Operator & Assignments



 arithmetic operators

Arithmetic Operators


1.If we are applying any arithmetic operators between two variables a and b, then the result type always will be max(int, type of a type of b).In java, every arithmetic operator returns minimum type is the int type.let's understand more about this by the following table.








javabychetan.com




example 1:-
System.out.println('a'+'b');

output is =195




     hint :-(a=>97 ,b=>98 unicode values)

example 2:-
System.out.println('a'+0.16)
output is => 97+0.16  => 97.16

2.Infinite Role:



  • In integral data types(byte, short, int, long) doesn't have any representation for infinity.if we are applying then we won't get any compile time errors but while running the program we will get RuntimeException saying"ArithmeticExceptionDevide by Zero".

Java - Arithmetic Operators / Chapter -2 /Operator & Assignments

javabychetan.blogspot.com

1.If we are applying any arithmetic operators between two variables a and b ,then the result type always will be max(int ,type of a,type of b).In java, every arithmetic operator returns minimum type is the int type.let's understand more about this by the following table.


javabychetan.blogspot.com
     example 1:-
    System.out.println('a'+'b');

    output is =195                          hint :-(a=>97 ,b=>98 unicode values)

     example 2:-
    System.out.println('a'+0.16)
    output is => 97+0.16  => 97.16


2.Infinite Role:

  • In integral data types(byte,short,int,long) doesn't have any representation for infinity.if we are applying then we won't get any compile time errors but while running the program  we will get RuntimeException saying"ArithmeticExceptionDevide by Zero".

Java - Increment and Decrement Operators / Chapter -1 /Operator & Assignments





javabychetan.blogspot.com


Increment Operator


In java, there are two types of increments operators



  • Pre-Increments          b = ++a;

  • Post-Increments        b =  a++;



Decrement Operator



In java, there are two types of decrements operators



  • Pre-Decrements          b  = --a;

  • Post-Derement           b  =  a--;



Lets understand more by following examples:-

Java - Increment and Decrement Operators / Chapter -1 /Operator & Assignments

javabychetan.blogspot.com

Increment Operator

In java, there are two types of increments operators

  • Pre-Increments          b = ++a;
  • Post-Increments        b =  a++;
Decrement Operator

In java, there are two types of decrements operators


  • Pre-Decrements          b  = --a;
  • Post-Derement           b  =  a--;
Lets understand more by following examples:-

int a=10;
int b;
Expression               initial value of a              value of b           after the completing expression final value of a
b = ++a                            10                               11                                11
b = a++                            10                               10                                11
b = -- a                            10                                9                                  9
b = a--                             10                                10                                9

Rule 1.
We can apply increment & decrement operators only for variables but not for constant value.
If we are trying to apply for constant value then we will get Compile Time Error.
example 1:-

Java - Command Line Arguments / Chapter - 8 /Language Fundamental


javabychetan.blogspot.com

java command line arguments 


1.The arguments which are passing from command-prompt are called command-line arguments.
With these command-line arguments, JVM will create an array & by passing that array as arguments
JVM will call main( ) method.
for  example:-
class Test
{
      public static void main(String [ ] args)

     {


       System.out.println("javabychetan.blogspot.com ");

       for(int i=0;i<args.length;i++)

           {

           System.out.println(args[i]);

           }

       }

}

Java - Command Line Arguments / Chapter - 8 /Language Fundamental

javabychetan.blogspot.com


1.The arguments which are passing from command-prompt are called command-line arguments.
  With these command-line arguments, JVM will create an array & by passing that array as arguments
  JVM will call main( ) method.
for  example:-
class Test
{

      public static void main(String [ ] args)
     {

       System.out.println("javabychetan.blogspot.com ");
       for(int i=0;i<args.length;i++)
           {
           System.out.println(args[i]);
           }
       }
}

Flipkart End Of Season Sale






© Copyright 2017 Javabychetan.blogspot.com