Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/coreJava/AssignmentOperators.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package coreJava;

public class AssignmentOperators {

public static void main(String[] args) {
//5. Assignment = += -+ *= /= %=

int a=10;
int b=10;
a+=5; //a=a+5;
b=b-5; //b=b-5;
System.out.println(a);
System.out.println(b);

int c=10;
a*=2; //c=c*2;
System.out.println(c);

int d=10;
d/=2; //d=d/2;
System.out.println(d);

int e=10;
e%=2; //e=e%2;
System.out.println(e);

/* difference b/w == = ?
* == is relational operators it compares the value
* = is assignment operator , it assigns the value
*/

}

}
220 changes: 110 additions & 110 deletions src/coreJava/DataTypes.java
Original file line number Diff line number Diff line change
@@ -1,134 +1,134 @@
package coreJava;

public class DataTypes {

public static void main(String[] args) {
package coreJava;

//variables

//int s; //declaration
//s=100; //assignment

int s=100; // declaration+assignment
System.out.println(s);

s=200;
System.out.println(s);
public class DataTypes {

public static void main(String[] args) {

//variables

//int s; //declaration
//s=100; //assignment

int s=100; // declaration+assignment
System.out.println(s);

s=200;
System.out.println(s);

/*
// approach1 // if all the variables belongs to different data types
int p=1;
int o=2;
int i=3;
*/
/* approach2 // only if allthe variable are belongs to same data type

/* approach2 // only if all the variable are belongs to same data type
int p,o,i;
p=1;
o=2;
i=3;
*/

// approach3 //only if all the variable are belongs to same data type
int p=1,o=2,i=3;
int p=1,o=2,i=3;

//for meaningful message in print statement we can use concatenation method
System.out.println("The Value of p is :"+p);
System.out.println("The Value of o is :"+o);
System.out.println("The Value of i is :"+i);
System.out.println("The Value of p is :"+p);
System.out.println("The Value of o is :"+o);
System.out.println("The Value of i is :"+i);

// in single line we printed all variable values
System.out.println(p+""+o+""+i+"");
System.out.println(p+""+o+""+i+"");

// in print statement we used join method for each value with ""


//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
// Data types
// Numeric Data Types
int a=100, b=200;
System.out.println("The Value of a is :"+a);
System.out.println("The Value of b is :"+b);
System.out.println(a+b);
System.out.println("The sum of an and b is : "+(a+b));
byte by=125;
System.out.println(by);
short sh=32767;
System.out.println(sh);
long l=21212121234443534L; // literal is needed
// L should add, it can be lower or uppercase
System.out.println(l);
// Decimal numbers - float, double
float item_price=15.5f; // literal is needed
//f should add, it can be lower or uppercase
System.out.println(item_price);
double dbl=1234.4343412;
System.out.println(dbl);
// characters
char grade='A'; // single character in single quotes - ''
System.out.println(grade);
String name="Harish"; // String is non-premitive type and multiple characters with double quotes - ""
System.out.println(name);
//char ch='abc'; //invalid
//Stirng ch='abc';//invalid
//String ch='A';//invalid
String ch="A"; //valid
System.out.println(ch);
boolean bl=true; //allows only true or false
System.out.println(bl);
boolean bl1=false;//allows only true or false
System.out.println(bl1);
//boolean bl="true";//invalid
//boolean bl="false";//invalid
//String bl=true;//invalid
String bl2="true";//valid
//----------------------------------------------------------------------
//difference between variable and const/final
int x=100;
System.out.println(x);
x=200;
System.out.println(x);
final int y=300;
System.out.println(y);
// y=400;// not allowed
//System.out.println(y);
// variables declaration without final keyword we can change the values but wiht final keyword we cnat chaneg the value. in javascript instea dof final, const keyword is used.
//java is statistically typed programming language
//python is dynamically typed programming language
//javascript is dynamically typed scripting language
//Example :
int q=100;
//x="welcome";//it is not allowed in java but in javascript and python it is allowed
//in python or javascript we no need to specify the data types explicitly.
/*
r=100;
r="welcome";
*/
//it is allowed in dynamically typed programming language - javascript / python

// Numeric Data Types

int a=100, b=200;
System.out.println("The Value of a is :"+a);
System.out.println("The Value of b is :"+b);
System.out.println(a+b);
System.out.println("The sum of an and b is : "+(a+b));

byte by=125;
System.out.println(by);

short sh=32767;
System.out.println(sh);

long l=21212121234443534L; // literal is needed
// L should add, it can be lower or uppercase
System.out.println(l);

// Decimal numbers - float, double

float item_price=15.5f; // literal is needed
//f should add, it can be lower or uppercase
System.out.println(item_price);

double dbl=1234.4343412;
System.out.println(dbl);

// characters

char grade='A'; // single character in single quotes - ''
System.out.println(grade);

String name="Harish"; // String is non-premitive type and multiple characters with double quotes - ""
System.out.println(name);

//char ch='abc'; //invalid
//Stirng ch='abc';//invalid
//String ch='A';//invalid
String ch="A"; //valid
System.out.println(ch);

boolean bl=true; //allows only true or false
System.out.println(bl);

boolean bl1=false;//allows only true or false
System.out.println(bl1);

//boolean bl="true";//invalid
//boolean bl="false";//invalid

//String bl=true;//invalid
String bl2="true";//valid

//----------------------------------------------------------------------

//difference between variable and const/final
int x=100;
System.out.println(x);
x=200;
System.out.println(x);

final int y=300;
System.out.println(y);
// y=400;// not allowed
//System.out.println(y);

// variables declaration without final keyword we can change the values but wiht final keyword we cnat chaneg the value. in javascript instea dof final, const keyword is used.

//java is statistically typed programming language
// python is dynamically typed programming language
//javascript is dynamically typed scripting language

//Example :

int q=100;
//x="welcome";//it is not allowed in java but in javascript and python it is allowed
//in python or javascript we no need to specify the data types explicitly.

/*
r=100;
r="welcome";
*/
//it is allowed in dynamically typed programming language - javascript / python

}

Expand Down
39 changes: 39 additions & 0 deletions src/coreJava/DecrementOperators.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package coreJava;

public class DecrementOperators {

public static void main(String[] args) {
//5.Decrement operators --

//case1
int a=10;
System.out.println(a);

// a=a-1;
//instead of writing 2 times "a" we can use below code
a--;
System.out.println(a);

//case2 post decrement

int b=10;
int res=b--;
System.out.println(res);

//expected o/p is 11 but we received 10 because first 10 is assigned to res then value is decrement with a++
//first assignment is happen then decrement will happen

System.out.println(a);

//case3 Pre increment

int c=10;
int res1=--c;
System.out.println(res1);
// first decrement the value then assignment is happen

System.out.println(c);

}

}
40 changes: 40 additions & 0 deletions src/coreJava/IncrementOperator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package coreJava;

public class IncrementOperator {

public static void main(String[] args) {

//4.Increment & Decrement operators ++ --

//case1
int a=10;
System.out.println(a);

// a=a+1;
//instead of writing 2 times "a" we can use below code
a++;
System.out.println(a);

//case2 post increment

int b=10;
int res=b++;
System.out.println(res);

//expected o/p is 11 but we received 10 because first 10 is assigned to res then value is incremented with a++
//first assignment is happen then increment will happen

System.out.println(a);

//case3 Pre increment

int c=10;
int res1=++c;
System.out.println(res1);
// first increment the value then assignment is happen

System.out.println(c);

}

}
Loading