// Online Java Compiler
// Use this editor to write, compile and run your Java code online
public class Main {
public static void main(String[] args) {
// System.out.println("hello SaeeAM");
// //print no in java
System.out.print(3*2);
System.out.print(55);
System.out.println(375.6);
//java variable
/*
String = "SaeeAM" LIke that
int = 125, 546
float = 12.56 and 254.23 Like that
char = 'S', 'b' LIke that signal character of english alphabet
boolean = true or false LIke that
*/
String saeeam= "SaeeAM Startup"; //String define like that
int myint = 15; //define like that for int
myint = 25; // Overright this
float myfloat = 5.95f; //f is required that tell is float value
char mychar = 'S'; // Singal char show like that signal quotes take experiment with double quotes work or not.
boolean mybool = true; // Boolean value define like that.
System.out.println(saeeam);
System.out.println(myint);
System.out.println(myfloat);
System.out.println(mychar);
System.out.println(mybool);
// System.out.print(); // help to help variable or anything u //want to print
// System.out.println(); // Same but little bit difference print every time in new line;
//to Combine both text and a variable, use the + character
System.out.println("Hello "+saeeam +" "+ mybool);
System.out.println("SaeeAMint "+myint);
System.out.println("SaeeAMfloat "+myfloat);
System.out.println("SaeeAMchar "+mychar);
System.out.println("SaeeAMbool "+mybool);
//float value not assign in int variable so careful handle this things
float myadd = myint+myfloat;
System.out.print(myadd);
//Do this with int
int x = myint *2;
int y = myint *3;
int z = myint *4;
System.out.println(x+y+z);
//Do this with Float
float a = myfloat *2;
float b = myfloat *3;
float c = myfloat *4;
System.out.println(x+y+z);
// One Value To Multiple Variables float
int d, e, f;
d= e= f= 50;
System.out.println(x+y+z);
// One Value To Multiple Variables with float
float x, y, z;
x= y=z= 50.28f;
System.out.println(x+y+z);
//Java Identifiers how recognise variable best or not
int minutesPerHour = 60; //Good Way to declear
int m = 60; //ok but not the way to declear how to recognise
//Data Type
//Byte Integer Type data Use like that
byte myByteNum = 100;
System.out.println(myByteNum);
//Short how to Use
short myShortNum = 5000;
System.out.println(myShortNum);
// //Long How to use
long myLongNum = 1500000000000000L;
System.out.println(myLongNum);
// //Double Data Type Example
double myDoubleNum = 19.7466d;
System.out.println(myDoubleNum);
// Boolean Types
boolean myBooleanNum = true;
boolean myBooleanNum1 = false;
System.out.println(myBooleanNum);
System.out.println(myBooleanNum1);
// // Ascii Value can be fount any int number through below example
char myVar1 = 68, myVar2 = 66, myVar3 = 67;
System.out.println(myVar1);
System.out.println(myVar2);
System.out.print(myVar3);
//Data Casting --> Two Type
//1st Widening Casting
//byte -> short -> char -> int -> long -> float -> double
// //Byte -> Short
byte mybyte = 9;
short myshort = mybyte; //Automatic Casting: int to double
// //Char -> Int
char mychar = 'S';
int myint = mychar;
// //Long -> Float
long mylong = 95665656666L;
float myfloat = mylong;
// //Float -> Double
float myflot = 5.95f;
double myDouble = myflot;
System.out.println(myshort);
System.out.println(myDouble);
System.out.println(myint);
System.out.println(myfloat);
//Narrowing Casting
double myDouble = 9.78d;
int myInt = (int) myDouble; //Manual casting: double to int
System.out.println(myDouble);
System.out.print(myInt);
}
}
No comments:
Post a Comment