1:40 pm - Wednesday October 17, 2018

Byte Example Program for floatValue()

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
/**
@author:Candidjava
@Description:This  java program shows how to change from float value to byte value.
 */
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class FloatToByte {
	
	public static void main(String[] args) {
	
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(
					System.in));
			System.out.println("Enter the float value:");
			float myfloat = Float.parseFloat(br.readLine());// create object for
															// float
			byte mybyte = (byte) (myfloat); // create object for byte
			System.out.println(myfloat + "is changed to byte value  " + mybyte);
		}
		catch (Exception e) {
		}
	}
}

output:
D:/candidjava/Lang/Byte>javac FloatToByte.java
D:/candidjava/Lang/Byte>java FloatToByte

Enter the float value:
15.87
15.87 is changed to byte value 15

BACK

Filed in: Z-A All Java Codes

Comments are closed.