diff --git a/Typconversion.class b/Typconversion.class new file mode 100644 index 0000000..b7ac32b Binary files /dev/null and b/Typconversion.class differ diff --git a/Typconversion.java b/Typconversion.java index ea5d37c..f3d4328 100644 --- a/Typconversion.java +++ b/Typconversion.java @@ -1,5 +1,14 @@ +import java.util.*; public class Typconversion { - + public static void main(String args[]){ + System.out.println("Enter a number:"); + Scanner sc = new Scanner(System.in); + int x = sc.nextInt(); + System.out.println("Now we will convert it into float data type:-"); + float y = x; + System.out.println(y); + } + // This is called implicit or widening type conversion. } /*1. Type Conversion occurs when we convert a data type into another data type. 2. For Conversion, data type should be compatible with another data type e.g. we can diff --git a/Typecast.class b/Typecast.class new file mode 100644 index 0000000..47d3ac0 Binary files /dev/null and b/Typecast.class differ diff --git a/Typecast.java b/Typecast.java new file mode 100644 index 0000000..5d941b5 --- /dev/null +++ b/Typecast.java @@ -0,0 +1,12 @@ +public class Typecast { + public static void main(String args[]){ + float a= 10.899f; + int b = (int)a; + System.out.println(b); + } + +} +/* + TypeCasting/Explicit/Narrowing Conversion:- + + */