answersLogoWhite

0

It depends on what you mean by "convert an int to char".

If you simply want to cast the value in the int, you can cast it using Java's typecast notation:

int i = 97; // 97 is 'a' in ASCII

char c = (char) i; // c is now 'a'

If you mean transforming the integer 1 into the character '1', you can do it like this:

if (i >= 0 && i <= 9) {

char c = Character.forDigit(i, 10);

....

}

User Avatar

Wiki User

15y ago

What else can I help you with?

Continue Learning about Engineering

How do you convert an integer to Boolean array list in java?

You cannot. An Integer is a numeric value whereas a boolean array list is a collection of a number of true or false values. So, you cannot convert either into the other


Can an integer data type in c plus plus stores character value?

no


Why character is an integer?

A character type (char) is not an integer, but it is an integral type and can therefore be used to store integers and perform integral arithmetic. However, in order to output the value as an integer rather than as a character code, the character must be converted (cast) to an integer. This can be done explicitly or implicitly. The only thing to be wary of is when mixing signed/unsigned representations as this may cause narrowing.


What restriction must be satisfied by all of the data items represented by an array?

An array is a group of related items that share a common name.All these elements are stored consecutively. An array must be declared before its use in the program. Array size must be specified All Array elements must be assigned to any value for assignment the value. Partial initialization of elements of an array is not allowed. Size must be integer constant enclosed within square brackets The name of the array indicates starting address of an array. Each individual element of array is accessed by a subscript.


Why numeric arrays do not end with a '0' in C programming language?

The value zero is a perfectly valid numeric array element in its own right. If we used the value zero to mark the end of a numeric array in the same way we use a null-terminator to mark the end of a string (a character array), we'd have no way of representing the value zero within the array itself. Thus when working with numeric arrays, we must keep track of the array length independently of the array.

Related Questions

What is the default value of the array elements in an integer array?

'0' Try this: public static void main(String[] args){ } The output would be 0 even though you did not initialize any value in the int array.


How do you convert an integer to Boolean array list in java?

You cannot. An Integer is a numeric value whereas a boolean array list is a collection of a number of true or false values. So, you cannot convert either into the other


True or false the controlling expression of a switch statement must have a value that is an integer or a character?

False. In C++, it must evaluate to an integral type, which includes floating point types. In other languages, a character array or other object may also be acceptable.


What advantage are there in defining an array size in term of symbolic constant rather than a fixed integer value?

It may be possible to generalise results to other integer values.


Can an integer data type in c plus plus stores character value?

no


How do you write a java method to find the second largest integer in an array by using only one loop?

Use two variables to store the largest, and the second-largest integer. Update those in a loop, for every element in the array. Initial values might be the lowest permissible value for the int, long, double, or whatever value you use.


How do you get the absolute value of positive integer?

The absoluate value of a positive integer is the integer itself.The absoluate value of a positive integer is the integer itself.The absoluate value of a positive integer is the integer itself.The absoluate value of a positive integer is the integer itself.


What is array in C languange?

An array is a contiguous block of data in memory. When you declare an array in C you need to give it a type and a name (like a normal variable), plus you need to give it a size. // normal integer variable x int x; // array of 10 integers int x[10]; Remember that the variable x is actually just a pointer, or reference, to a point in memory. This point in memory is the start of the array, so the value at x[0] is the first value in the array, x[1] is the second, and so on. Also remember that C has no bounds checking, so you can, indeed, read any value past the maximum. x[3474] would return an integer value, but it's going to be some part of memory that is not in your array. Attempting to change this value could result in something very bad happening.


Why character is an integer?

A character type (char) is not an integer, but it is an integral type and can therefore be used to store integers and perform integral arithmetic. However, in order to output the value as an integer rather than as a character code, the character must be converted (cast) to an integer. This can be done explicitly or implicitly. The only thing to be wary of is when mixing signed/unsigned representations as this may cause narrowing.


What restriction must be satisfied by all of the data items represented by an array?

An array is a group of related items that share a common name.All these elements are stored consecutively. An array must be declared before its use in the program. Array size must be specified All Array elements must be assigned to any value for assignment the value. Partial initialization of elements of an array is not allowed. Size must be integer constant enclosed within square brackets The name of the array indicates starting address of an array. Each individual element of array is accessed by a subscript.


Differentiate string and character?

A character is an integer value which stores an encoding for a printable (though not necessarily "visible") symbol. A string is a list of characters.


Function pointer that will point to a function that takes integer value and return character?

Answerchar (*funcp(int));