Tuesday, 28 February 2017

How to use java code for type casting

//********************************Start**************************

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package javaapplication1;

/**
 *
 * @author HP
 */
public class Java_Type_Casting {
 public static void main(String args[])
    {

        byte b;
        int i = 257;
        double d = 323.142;

        System.out.println("Conversion of int to byte.");
        b = (byte) i;
        System.out.println("i is " + i + " and b is " + b);

        System.out.println("\nConversion of double to int.");
        i = (int) d;
        System.out.println("d is " + d + " and i is " + i);

        System.out.println("\nConversion of double to byte.");
        b = (byte) d;
        System.out.println("d is " + d + " and b is " + b);

    }
}

//********************************End***************************

No comments:

Post a Comment

Welcome, happy learning

Charactor_At_Position

public class Char_At_Position { public static void main(String[] args) { String str = "Wankhede"; String rev=""...