How does the System.in.read() works?

Hi!I'm trying to read some chars from the console.So here is my code of reading the two chars:
       char ch1='\u0000';
       char ch2='\u0000';
       System.out.print("Enter the first char:");
       ch1=(char)System.in.read();
       System.in.read();
       System.out.print("Enter the second char:");
       ch2=(char)System.in.read();
       System.out.println("You have typed the following letters:"+ch1+" , "+ch2);My problem is that if I don't add the System.in.read(); line after reading the first char i wont be able to read the second.But I saw on a code on the net that they put it.So I've put it too but don't understand what it does.I mean the System.in.read(); function reads until it gets -1.But in my case it's gonna get '\n'.So how does this function works?Thank you!
Edited by: jcoder86 on Oct 9, 2009 5:36 AM

jcoder86 wrote:
Hi!I'm trying to read some chars from the console.So here is my code of reading the two chars:
char ch1='\u0000';
char ch2='\u0000';
System.out.print("Enter the first char:");
ch1=(char)System.in.read();
System.in.read();
System.out.print("Enter the second char:");
ch2=(char)System.in.read();
System.out.println("You have typed the following letters:"+ch1+" , "+ch2);My problem is that if I don't add the System.in.read(); line after reading the first char i wont be able to read the second.But I saw on a code on the net that they put it.So I've put it too but don't understand what it does.I mean the System.in.read(); function reads until it gets -1.But in my case it's gonna get '\n'.So how does this function works?Thank you!
Edited by: jcoder86 on Oct 9, 2009 5:36 AMThat's wrong. System.in.read() reads a byte from the stream. -1 is returned if the end of stream has been reached (that usually doesn't happen if you read from stdin)
The second System.in.read() is there to throw away the line terminator.

Similar Messages

  • How does the LCM rollback feature work in theory?

    Hi
    How does the LCM rollback feature work in theory?
    Let's say
    1. I've Webi report 'x' in QA system
    2. I promote a modified version of webi report 'x' from DEV to QA using LCM. So now I've 'x1' in QA.
    3. I "rollback" this promotion job in LCM. Which means I've get back 'x' in QA system.
    So does this mean that LCM kept a "backup" copy of 'x' in QA (CMS+filestore file backup) before overwriting with the promoted 'x1' from DEV?
    If yes, does it clear the 'x' anytime from QA? (maybe after second iteration of 'x2'?)
    Thanks

    I highly recommend you read the following blog posts that contains straight answers to common questions about the automatic update feature:
    Hello, Adobe Flash Player Background Updater (Windows)!
    Adobe Flash Player Background Updater for Mac is live!

  • How does the Mac App Store work?!

    Hey guys i recently posted this quesiton in a different area of the community but instead of being helped was just ridiculed for posting in the wrong place... +1 for helpfulness guys :/ lol Anyways... ive been told to ask in the development section.. I have a $9.99 app and it was sitting at 10th place in the top grossing apps a few weeks ago on the UK app store, now I noticed in the morning that it was ahead of an app which was 49.99 so i presumed that I must have sold at least 5 or 6 to be ahead of him (my idea of top grossing is quantity x price) but when itunesconnect released their reports in the afternoon it turned out that i'd only sold 1 copy.. so what im asking is basically how does the top grossing section work? and how regularly does it update? is it live? daily? etc
    Thanks in advance!

    Your rank is better than the other app because you've made a sale while they've made none. When you make a sale, you jump in the charts, and after that you slowly go down if you don't make another sale. In other words, the bottom of the charts has many apps that didn't make any sale recently. I've also noticed that if you make some sales in other countries than the current chart, that'll very slightly improve your rank.

  • Can anyone let me know how does the system calculate forecast strategy?

    Hi all,
    I am new in Demand planning,,  I can see a couple of Forecast strategy used in  the production. I would like to know how does the system does the calculation for the forecasting strategies like
    36     Median method
    13     Moving average
    94     Linear regression
    etc.
    Can anyone pls guide me how does the system do the calculation and how to validate those calculations!!
    Thanks
    Pooja

    Hi Pooja,
    The below link will contain the detailed list of all forecast strategies alongwith how
    it will be calculated alongwith the formulas
    http://help.sap.com/saphelp_scm70/helpdata/EN/ac/216b6e337b11d398290000e8a49608/frameset.htm
    Please confirm whether this helps you to resolve your query
    Regards
    R. Senthil Mareeswaran.

  • EDI-How does the Inbound File process work?

    Hi
    How does the Inbound process work in EDI
    When a file is put in the Inbound EDI directory of the App server how does the system start the process?
    Which programs are called/triggered?
    How does the Inbound process work?
    Please be brief and precise.

    Hi
    Check the links
    Check these links.
    http://help.sap.com/saphelp_erp2004/helpdata/en/dc/6b835943d711d1893e0000e8323c4f/content.htm
    http://www.sapgenie.com/sapgenie/docs/ale_scenario_development_procedure.doc
    http://edocs.bea.com/elink/adapter/r3/userhtm/ale.htm#1008419
    http://www.netweaverguru.com/EDI/HTML/IDocBook.htm
    http://www.sapgenie.com/sapedi/index.htm
    http://www.sappoint.com/abap/ale.pdf
    http://www.sappoint.com/abap/ale2.pdf
    http://www.sapgenie.com/sapedi/idoc_abap.htm
    http://help.sap.com/saphelp_erp2005/helpdata/en/0b/2a60bb507d11d18ee90000e8366fc2/frameset.htm
    http://help.sap.com/saphelp_erp2005/helpdata/en/78/217da751ce11d189570000e829fbbd/frameset.htm
    http://www.allsaplinks.com/idoc_sample.html
    http://www.sappoint.com/abap.html
    http://help.sap.com/saphelp_erp2004/helpdata/en/dc/6b835943d711d1893e0000e8323c4f/content.htm
    http://www.sapgenie.com/sapgenie/docs/ale_scenario_development_procedure.doc
    http://edocs.bea.com/elink/adapter/r3/userhtm/ale.htm#1008419
    http://www.netweaverguru.com/EDI/HTML/IDocBook.htm
    http://www.sapgenie.com/sapedi/index.htm
    http://www.allsaplinks.com/idoc_sample.html
    http://www.sapgenie.com/sapgenie/docs/ale_scenario_development_procedure.docs
    Please check this PDF documents for ALE and IDoc.
    http://www.sappoint.com/abap/ale.pdf
    http://www.sappoint.com/abap/ale2.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCMIDALEIO/BCMIDALEIO.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCMIDALEPRO/BCMIDALEPRO.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/CABFAALEQS/CABFAALEQS.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVEDISC/CAEDISCAP_STC.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVEDI/CAEDI.pdf
    Check below link. It will give the step by step procedure for IDOC creation.
    http://www.supinfo-projects.com/cn/2005/idocs_en/2/
    Reward points if useful
    Regards
    Anji

  • How does the system identifies whether we use Psotive or Negative Time Mngt

    Dear All,
    How does the system identifies whether we use Psotive or Negative Time Management.
    Appreciate your early response.
    Regards
    Rajesh

    Hi
    1. In positive time management we record the actual time of the employee working in organization and following are the infotypes we need to maintain in master data,
              1. Organztion Assignement [0001]
              2. Personal Data [0002]
              3. Absence Quota [2006]
              4. Planed working time [0007] with the time management status " if you are using PDC then "2" " Or "1. Time evaluation actual time".
              5. Time Recording Info [0050]
    2. In Negative time management we are only recording the time deviation like "Absence, Illness, Leave" and following are the Infotype we need to maintain in master data,
             0001, 0002,0007 with time management status "0" i.e No time evaluation and 2006.
    Best of Luck
    Swapnil

  • How does the system calculate nondeductible taxes?

    Dear Gurus,
    How does the system calculate nondeductible taxes?
    Thanks..

    The sytem calculates the Taxes based on the Tax rates maintained in a tx code, the Caluctaion is based on the taxing procedure assigned to the Country.
    Non deductible tax is identified based on the Account key assigned to the Condition type in the Taxing procedure.
    The Non deductible tax Account keys are
    NAV - Non-deduct.input tax ( This will distribute the tax into a new line item)
    NVV - Non-d.input tax dist ( this will Distribute to relevant expense/revenue items )

  • How does the system knows age or seniority is crossed for so and so... EE

    Hi Experts,
    In my project we have configured some Health plans based on ages and seniority,
    Employee can enroll in to the plan when they reach the age or seniority,
    my question is how does the system knows  age or seniority is crossed for so and so... EE, where exactly we do this setups
    Pleae let me know your valuable answers
    Regards
    Sreeni

    hr_entry_date and you can use various
    fm to calculate this, It reads 0019, 0041 or Hdate feature
    3QP8                           Time related calculation function mod.
    HR_AUPBS_SENIORITY             Calculate the whole length of service of employee
    3RP3A                          Leave schem proration modules
    SGPS_LS_SENIORITY_CALCULATION  Function for seniority calculation for Singapore Leave Scheme
    HRDO
    HR_DE_PBS_SENIORITY_PERIODS
    HRFPBS4AV0
    HR_PSF_AV_ANC_INPUT_SENIORITY
    HRF_METADATA_IT
    HRF_READ_SENIORITY_IT

  • How does the system calculate taxes?

    Dear All,
    How does the system calculate taxes?
    Can anybody explain in detail how the values will flow from PB00 / PBXX to BASB ?
    Is this flow will remains same in both deductible & non deductible taxes ..??
    Pls explain
    With Regds

    Hi
    Just remove the base type 362 in the taxing procedure & check if your tax is calculating or not.
    The Tax determination still works.
    FORM FRM_KOND_BASIS_362.
    *Application country specific
    *This alternate base value is to be attached to BASB. This routine
    *fetches KZWI6 captured in the pricing procedure.
    Thanks & Regards
    Kishore

  • How does the widgets HTML snippet work on iweb?

    How does the widgets HTML nippet work on Iweb? and when should you use it?

    Joe R wrote:
    I'm creating Tool Tip definitions for the Operators in the Filter on the Interactive Reports. I was looking for a definition for the 'Contains' operator and from what I've found this operator is used to do a text search and it returns a relevance score for every row selected.The IR "Contains" filter is not the same as the Oracle Text <tt>contains</tt> operator.
    The IR "Contains" filter performs a simple string comparison on all of the column values returned. It does not make use of any Oracle Text indexes on the underlying data.
    Despite < a href="https://forums.oracle.com/forums/thread.jspa?messageID=2434666">vague promises of enhancement</a>, no Oracle Text support has yet been included in Interactive Reports.

  • GRC - Role Expert v5.2: how does the Transaction Usage functionality work

    Hi All,
    re: GRC - Role Expert v5.2: how does the Transaction Usage functionality work
    We are implementing GRC suite v5.2, but specifically my question is regarding Role Expert:
    SAP documentation states that it is possible to use Role Expert to do the following: for roles allows you to see if, or how much, a transaction is being used, when it was last used, and who used it.
    My question is how without Audit Log or RBE?
    Let me know if you have ever used this functionality and if it requires the SAP Back-End Audit Log to be turned on or RBE.
    Thanks in advance!

    Hi Gary,
    You dont need a RBE tool activation to get the successful transaction usage log with Role Expert.
    Role Expert functionality allows you to log all the transactions that have been added/deleted to the role that is changed. Also when you create a new role via the Role Expert then automatically the transaction log starts.
    If you go the "History" tab in the Role Expert, then you can find all the last changes made to the role.
    Also you can go to the "Risk Analysis" tab to find the log of Risk Analysis performed with the added tcodes.
    Hope this helps.
    Thanks,
    Kiran Kandepalli.

  • How does the shake to shuffle work on ipod touch 4g?

    So, i want to know how does the shake to shuffle work, i opened the music player and started playing a song but when i shake the ipod, nothing happens, the option of shuffle on the screen is still white and when the song currently playing ends, the next one in alphabetical order starts. The shake to shuffle option in settings is On.

    The iPod can only tether via Bluetooth for internet connectivity to an iPhone. It will connect to other phones to tether for internet connectivity if the phones can act like a wifi hotspot.

  • How does the system knows hire action first

    Hi all,
    Iam new to this community, recently i have joined as an SAP HR trainee ,and i am undergoing SAPHR training Programme.
    why can't the system allow us to do promotion action before Hire action?where do we configure this to make it happen, how does the system knows to do the Hire action first, where are the settings for this..
    Swathi

    hai
    there are a number of programmes running in the back groung when u do any application.
    the validations will be written in them
    when u try to do something through the programe running at the back ground does these validations  like the example u have taken when u do the promotion action it checks whether actions exists or not if not then it throws the error written in the program.
    regards
    nalla

  • How does the system Validyne pressure transducer -- Validyne CD280-Dual-- SCB-68-- PCI-6024E-- LABVIEW work and how can we calibrate the pressure transducer?

    Hello there,
    I am completely new to the LABVIEW software.
    I am learning an existing LABVIEW code of my pressure acquisition system (attached) which has the data path as following: Validyne pressure transducer --> Validyne CD280-Dual--> SCB-68--> PCI-6024E--> LABVIEW and I have some question:
    1. How does the complete system from transducer to the LABVIEW work? ie if we apply the pressure at the transducer, it will change the resistance of the transducer then ....?
    2. How can I find the equation which express the relationship between the pressure and the voltage at the oupt of the Validyne CD280-Dual in the LABVIEW?
    3. If I want to do the calibration for the transducer, what are steps?
    Thanks,
    Solved!
    Go to Solution.
    Attachments:
    Experiment.vi ‏143 KB
    Plogger.vi ‏21 KB

    Hello there,
    I do not understand what subVIs you are refering to but I have tried to run the LABVIEW program using the files I attached and it worked fine (pls see the attached pressure plot).
    As I mentined before, I am new to LABVIEW so maybe I do not know.
    Thanks,
    Attachments:
    Pressure plot.jpg ‏111 KB

  • How does the system know...how to read customore pricing procedure

    Hie Guys, Can you please let me know how the system knows How to ready customer pricing procedure.
    system always reads customer pricing procedure from Sold to  party. can you please let me know if there is any setting for the system to know how to ready the customer pricing procedure. what should be done if we want the system to read it from ship to party?
    thaks!
    Marry.

    Dear,
    Seems like you can get the help of abaper and see at what point system check the different combination for pricing procedure determination.
    If there is any EXIT / Enhancement available at this point, you can write a logic to fetch the customer pricing procedure from the SHIP TO PARTY Master data.
    Thanks & Regards,
    Hegal K Charles

Maybe you are looking for

  • Windows 7 not seeing iPod classic 80GB

    I can't seem to get my ipod to load onto my computer. It WILL show up in devices and printers, and in the device manager. it will NOT show up in my explorer or in itunes. furthermore, itunes will freeze up entirely once i plug in my ipod, and it can'

  • I don't want to end up with a dynamic drive.

    My existing C: drive is running out of free space. I also want to replace it with a new SSD drive for quicker start-up. I cloned the C: drive (which also included a recovery partition and a D: Data partition) onto the SSD disk. I deleted the duplicat

  • APP --- SOME DOUBTS.....PLZ HELP

    HI GUYS,, I have some doubts in APP. 1. why do we give next payment date in F110 while we are running payment..... 2. can we do partial payment for one line item through running APP.... please help me out.. Thanks in advance Regards, pavan Moderator:

  • Photoshop workspace and setting reset after CC update

    Hi, I downloaded updates this morning via Adobe CC desktop app, now all of my workspace settings, preferences, extensions, brushes, actions, patterns etc have been reset to factory by the look of it. I tried going to Photoshop > (my username) > Downl

  • Help!!!....My MacBook Pro ,running on OS X Mavericks, won't reboot

            After my antivirus system detected a virus I tried to open Chrome but didn't do anything...My computer kinda froze so i tried to restart. After it restarted, it stayed in the grey background with the apple logo and the little circle spinning.