answersLogoWhite

0

it is the same as an int, String, or any of the others:

float myVar = 5.7f;

If you try to assign a decimal number you must place an "f" at the end, otherwise Java will assume you are trying to assign a double.

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

How do you declare an array of 8 floats?

In C float a[8]; In Java float a[] = new float[8];


How can I convert a float to a double in Java?

To convert a float to a double in Java, you can simply assign the float value to a double variable. Java will automatically perform the conversion for you. Here's an example: java float floatValue 10.5f; double doubleValue floatValue; In this example, the float value 10.5f is assigned to the double variable doubleValue, which will now hold the converted double value.


How do you declare a variable with initial value of 20.1234?

float myVariable = 20.1234;


What is out of scope in returning objects in java?

if u declare variable in method & tray to use this variable outside the method then it is out of scope


Which qualifier is used to declare read-only variable in java?

A variable declared as final can't be modified, once a value is assigned.


How do you declare a pointer variable in c?

int* pint; // instantiate a pointer to an int. float* pflt; // instantiate a pointer to a float.


How do you declare many float variables in java?

You can declare them one by one. However, if you want to store lots of related data, you may want to consider using an array, where you use a single variable name (for example) for 1000 different items, and a number called an index to access the individual items.


Can a double value be assigned to float variable?

THIS IS FOR JAVA i don't know about anything about other languages yes it can be assignedthe syntax is:int (number) = (float) numberFOR EXAMPLE:int = a;a = (float ) 5.5;if the (float) is not there then in Java it gives an error saying precision loss of data type


How do you return an object in java?

With the command return, followed by an object variable. In the method header, you have to declare the return type as the class of the object.


How do youdeclare a variable in jsp?

You declare a variable the same in a JSP as you do in a servlet. Let's say you want to declare a String variable called "foo" and you wanted to assign it a value of "bar." You would do this: String foo = "bar"; Of course, in a JSP, any Java code needs to be enclosed within <% and %>.


Is float is a keyword in java?

yes, float is keyword and data type in java


Which keyword is used to declare constants and variable?

Constants are defines using the final keyword.Variables are defined using the one of the keywords:charbooleanintdoublelongintStringTo use a constant you would have to put in something likedouble final pi = 3.14;