possible loss of precision error

possible loss of precision error

how do i fix this error " possible loss of precision found int required char ch = input.read()"

this is the code

import java.io.InputStreamReader; import java.io.IOException;

class Test1 {

public static void main(String[] args)

{
    InputStreamReader input = new InputStreamReader(System.in);
    char ch;


    System.out.println("Input y to continue");
    do
    {
        ch = input.read();
    }
    while (ch !='y');


    System.out.println("thank you for pressing Y" );
}

}

View Answers

April 4, 2011 at 11:27 AM

import java.io.InputStreamReader;
import java.io.IOException;

class Test1{
public static void main(String[] args) throws Exception{
    InputStreamReader input = new InputStreamReader(System.in);
    char ch;
    System.out.println("Input y to continue");
    do{
        int i=input.read();
        ch = (char)i;
    }
    while (ch !='y');
    System.out.println("thank you for pressing Y" );
}
}

Ads









Related Tutorials/Questions & Answers:
possible loss of precision error
possible loss of precision error  how do i fix this error " possible loss of precision found int required char ch = input.read()" this is the code import java.io.InputStreamReader; import java.io.IOException; class Test1
Itried all possible ways still getting thesame error
Itried all possible ways still getting thesame error  java.sql.SQLException: Io exception: Got minus one from a read call at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112
Advertisements
ModuleNotFoundError: No module named 'precision-predictiva'
: No module named 'precision-predictiva' error? Thanks   Hi..., ModuleNotFoundError: No module named 'precision-predictiva' error...ModuleNotFoundError: No module named 'precision-predictiva'  Hi
Weight loss
Weight loss   Is anybody able to help me. I am wanting to build... and output weight loss given time spent on activities import java.util.*; public... //calculate calories burnt //calculate weight loss //output
ModuleNotFoundError: No module named 'openerp-decimal-precision'
the ModuleNotFoundError: No module named 'openerp-decimal-precision' error? Thanks  ...-decimal-precision' error will be solved. Thanks...ModuleNotFoundError: No module named 'openerp-decimal-precision'  Hi
ModuleNotFoundError: No module named 'focal-loss'
;focal-loss' error? Thanks   Hi, In your python environment you...ModuleNotFoundError: No module named 'focal-loss'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'hmc_loss'
library, ModuleNotFoundError: No module named 'hmc_loss' error...ModuleNotFoundError: No module named 'hmc_loss'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'hmc
ModuleNotFoundError: No module named 'jax-loss'
library, ModuleNotFoundError: No module named 'jax-loss' error...ModuleNotFoundError: No module named 'jax-loss'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'jax
ModuleNotFoundError: No module named 'loss-landscapes'
'loss-landscapes' error? Thanks   Hi, In your python... named 'loss-landscapes' error will be solved. Thanks...ModuleNotFoundError: No module named 'loss-landscapes'  Hi, My
ModuleNotFoundError: No module named 'warp-loss'
-loss' error? Thanks   Hi, In your python environment you... python library, ModuleNotFoundError: No module named 'warp-loss' error...ModuleNotFoundError: No module named 'warp-loss'  Hi, My Python
tensorflow mixed precision
tensorflow mixed precision  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: tensorflow mixed precision Try to provide me good examples or tutorials links so that I can
ModuleNotFoundError: No module named 'online-triplet-loss'
: No module named 'online-triplet-loss' error? Thanks   Hi..., ModuleNotFoundError: No module named 'online-triplet-loss' error...ModuleNotFoundError: No module named 'online-triplet-loss'  Hi, My
losing precision converting from java BigDecimal to double
losing precision converting from java BigDecimal to double  losing precision converting from java BigDecimal to double
ModuleNotFoundError: No module named 'possible'
library, ModuleNotFoundError: No module named 'possible' error...ModuleNotFoundError: No module named 'possible'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named
Is it possible in SWT ?
Is it possible in SWT ?  I want drop down like google search (ie, when we type one letter then the word start with that are displayed). when the drop down list appear, then we can select one of word as our text box value. Can i
Weight Loss
Weight Loss Here we are providing complete information on Obesity and weight loss. This information will guide you in finding the right way in weight loss.... We are also discussing about Weight Loss surgery. There are many advantages
Error-
Error-   Hello, I would like to know about XSD file. I try to print XML file but I am getting error SAXException-- says Content is not allowed in prolog. Please help me
error
error  i have 404 error in my program plz tell me yhe solution about
error
error  i have 404 error in my program plz tell me yhe solution about
error
/ServletUserEnquiryForm.shtml getting an error given below SQLException caught: [Microsoft][ODBC SQL Server Driver]COUNT field incorrect or syntax error please suggest
Error
Error  I have created ajax with php for state and city. When I change state then city will not come in dropdown list and it give me error as 'Unknown Runtime Error'. This error come only in IE browser, but in other brower
error
error
error
error  When I deploye the example I have this message cannot Deploy HelloWorld Deployment Error for module: HelloWorld: Error occurred during deployment: Exception while deploying the app [HelloWorld
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern = /^\d{3,5
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
error
error  whats the error.............. import java.util.Scanner; public class g { public static void main(String[] args) { Scanner s=new Scanner(System.in); int d,x,y; System.out.println("Enter the first number

Ads