type casting and conversion

type casting and conversion

I am beginner and my query is Importance of type casting and conversion

View Answers

April 11, 2008 at 7:16 PM

Hi friend,

public class TypeCasting{
public static void main(String[] args){
boolean t = true;
byte b = 2;
short s = 100;
String str = "String";
System.out.println("All variable display like this.");
System.out.println("b = " + b );
System.out.println("s = " + s );
b = (byte)(t?1:0);
System.out.println("Value of b after conversion : " + b);
//Convert from boolean to short.
s = (short)(t?1:0);
System.out.println("Value of s after conversion : " + s);
}
}

------------------------------
Read for more information,

http://www.roseindia.net/java/









Related Tutorials/Questions & Answers:
type casting
type casting  what is type casting
Casting (Type Conversion)
Casting (Type Conversion)      ... to another type. Conversion of data from one type to another type is known as type casting. In java one object reference can be type cast into another object reference
Advertisements
Type casting
Type casting  how to type cast a string value to byte array
type casting
type casting  <--bean class-->method calllist is of object type... List (object type) <Object> totalList(int pi){ (adsbygoogle = window.adsbygoogle || []).push({}); try{ Query q= em.createQuery
type casting
type casting  int n=20; n=sizeof((char)(float)n); what is n value
type casting purpose
type casting purpose  what is type casting , could u explain with practical example
type casting - Java Beginners
type casting and conversion  I am beginner and my query is Importance of type casting and conversion  Hi friend,public class TypeCasting...;Value of b after conversion : " + b); //Convert from boolean to short. s
Type casting in java
word type casting is a conversion of one data type to another data type ...Type casting in java In this section you will learn about type casting in java. Type casting is to convert one type to another type. Java support two types
ModuleNotFoundError: No module named 'type-casting'
ModuleNotFoundError: No module named 'type-casting'  Hi, My Python... 'type-casting' How to remove the ModuleNotFoundError: No module named 'type-casting' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'type-casting'
ModuleNotFoundError: No module named 'type-casting'  Hi, My Python... 'type-casting' How to remove the ModuleNotFoundError: No module named 'type-casting' error? Thanks   Hi, In your python
Java Type Casting - Java Beginners
Java Type Casting  what is object type casting? give some example with related
Java type casting
Java type casting  What is Downcasting
Java type casting
Java type casting  Can a Byte object be cast to a double value
java type casting problem - Java Beginners
java type casting problem  what is type casting? what is the type of type casting? explain with example?  Hi Friend, Please visit the following link: http://www.roseindia.net/java/beginners/TypeCasting.shtml
Type casting the returned value of a method.
Type casting the returned value of a method.  Hi, How do you type cast the returned value of a method so that you can avoid creating a temporary...) will be of type OnOffButton. I want to avoid: OnOffButton btn = (OnOffButton
Type Conversion - Java Beginners
Type Conversion   Hai, rajanikanth, Please explain how to convert from integer value to a string value .In a database operation i want to convert... for conversion
Data Conversion from short to another type
Data conversion is the conversion of data from one type to another type. In this section we will learn about data conversion from short primitive type to another data type like String, boolean and char etc
Data Conversion from byte to another type
Data conversion is the conversion of data from one type to another type. In this section we will learn about data conversion from byte primitive type to another data type like String, boolean and char etc
Data Conversion from float to another type
Data conversion is the conversion of data from one type to another type. In this section we will learn about data conversion from float primitive type to another data type like String, boolean and char etc
Data Conversion from double to another type
Data conversion is the conversion of data from one type to another type. In this section we will learn about data conversion from double primitive type to another data type like String, boolean and char etc
Data Conversion from long to another type
Data conversion is the conversion of data from one type to another type. In this section we will learn about data conversion from long primitive type to another data type like String, boolean and char etc
Data Conversion from int to another type
Data conversion is the conversion of data from one type to another type. In this section we will learn about data conversion from int primitive type to another data type like String, boolean and char etc
Data Conversion from String to another type
Data conversion is the conversion of data from one type to another type. In this section we will learn about data conversion from String primitive type to another data type like int, boolean and char etc
HSSFCell to String type conversion
HSSFCell to String type conversion  Hello, Can anyone help me convert HSSFCell type to string. There is a solution in the following URL, but the method getWorkbook() is not defined for the class HSSFCell. Thanks in advance
Introduction to Type conversion in Struts
Introduction to Type conversion in Struts Type conversion is a mechanism... this powerful and important facility. In struts the type conversion is an mechanism... are converted into complex bean properties using this type conversion mechanism
Type conversion example
Type Conversion Example An example of type conversion is given below, which... in yyyy-mm-dd format Now make a type conversion class.ADS_TO_REPLACE_4 The class...;/title> <style type="text/css">@import url(css/main.css);<
How to customize property type conversion errors in Spring MVC 3.
How to customize property type conversion errors in Spring MVC 3.  Hi... the form, I receive a type conversion error: Failed to convert property value of type java.lang.String to required type java.lang.Integer for property age
Conversion from string data type into different data types.
Conversion from string data type into different data types.  string str="World id Beutifull"; char chr[20]; char* chrctr ; Qustion is -How to store the 'str' value in 'chr' and 'chrctr'? int abc; sprintf(abc ,"%s",str
What is casting?
What is casting?   Hi, What is casting? thanks
Casting in java - Java Beginners
Casting in java   Hi, I want to know Casting in detail... is implicit casting and Explicit casting . Implicit casting : Ex - assign... Explicit casting : Ex - Assign superclass variable to subclass
PHP Type Juggling
Type Juggling In PHP: Unlike other programming languages like C,C++ and Java... a float value to a variable then it becomes float type and if we assign... type, but if we add one integer and one float type variable then the result
PHP Integer Data Type
Learn PHP Integer Data type: In PHP integers can be decimal which is a normal... size of the integer data type is platform dependent. Usually the size of integer... be converted to float data type. PHP Integer Data Type Example:ADS_TO_REPLACE_2 <
currency conversion
currency conversion   hi frds.. I wan jsp code to convert currency in different formats??... if u know plz plz plz post it   Please visit the following link: http://www.roseindia.net/tutorials/I18N/currency
conversion Applet
conversion Applet  I am a java beginner.................. strong texthow to create JApplet that prompts the user to enter a distance in miles in a JTextField and then converts mile to kilometers and display the result as XX.XX
conversion
conversion
image conversion tools
image conversion tools  how many tools are available in image conversion at particularlly in java
Conversion from short to float
type value from console and provides a conversion to float type. The line... conversion from short type to float type. Code: import java.io.*; class... InputStreamReader(System.in)); System.out.println("---Data Conversion from short type
Conversion from short to double
a short type value from console and provides a conversion to double type. The line... to explicit conversion from short type to double type. Code: import java.io....Conversion from short to double: In this tutorial we will learn how to convert
ModuleNotFoundError: No module named 'conversion'
ModuleNotFoundError: No module named 'conversion'  Hi, My Python... 'conversion' How to remove the ModuleNotFoundError: No module named 'conversion' error? Thanks   Hi, In your python environment you
Conversion from short to byte
type value from console and provides a conversion to byte type. The line short... InputStreamReader(System.in)); System.out.println("---Data Conversion from short type...Conversion from short to byte: In this tutorial we will learn how to convert
Conversion from short to long
type value from console and provides a conversion to long type. The line short... InputStreamReader(System.in)); System.out.println("---Data Conversion from short type...Conversion from short to long: In this tutorial we will learn how to convert
Conversion from short to char
type value from console and provides a conversion to char type. The line short... InputStreamReader(System.in)); System.out.println("---Data Conversion from short type...Conversion from short to char: In this tutorial we will learn how to convert
Conversion from short to String
a short type value from console and provides a conversion to String type. The line... Conversion from short type to String type---"); System.out.println("Enter short...Conversion from short to String: In this tutorial we will learn how to convert
Conversion from short to boolean
a short type value from console and provides a conversion to boolean type...)); System.out.println("---Data Conversion from short type to boolean type...Conversion from short to boolean: In this tutorial we will learn how
javascript integer to string conversion
javascript integer to string conversion  How to Javascript Integer to String Conversion   <script type="text/javascript"> /** * print out the value and the type of the variable passed
Number conversion in JavaScript
Number conversion in JavaScript  How do you convert numbers between different bases in JavaScript
conversion of language in a project
conversion of language in a project  how can we convert the database code in the project dynamically
.wav file conversion
.wav file conversion   how to read .wav file and converd the data into text format
NSString to float conversion
NSString to float conversion  HI, I my iPhone and iPad application I have to convert NSString to float. Provide me example of NSString to float conversion. Thanks   Hi, Please see NSString to float conversion

Ads