Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5978871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:34:45+00:00 2026-05-22T21:34:45+00:00

Please explain the compiler behaviour in the below code snippet. Consider the text file

  • 0

Please explain the compiler behaviour in the below code snippet. Consider the text file contains the following text TOBE and the corresponding byte values are 84, 79, 66, 69

for(int i=0;i<4;i++){
    byte inByte=(byte) buffInputFile.read();
    system.out.println(inByte);
}

When i run this snippet i get the following output
84
79
66
69

But when i dubug at the for loop and step inside. The buffInputFile.read() shows me 84 at first and when assigned to inByte it is 79. and the output i get is

79,66,69,13 (13 is the carriage return).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:34:45+00:00Added an answer on May 22, 2026 at 9:34 pm

    I suspect you’ve got a debugger watch expression of buffInputFile.read() – which is reading the value from the stream in order to display it… but that value then isn’t available when the method is executed as part of the code. You’ve read that byte from the stream, so the next call to read() will read the next byte, exactly as it’s supposed to.

    In general it’s a very bad idea to execute methods with side effects within the debugger like this – it causes precisely this kind of confusion. If you just set a breakpoint on the line after the assignment, you can see the values that way.

    In short: this isn’t compiler behaviour going awry at all – it’s the way you’re using the debugger.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting the following compiler errors with the below code snippet: An object
Can you please explain me the difference between mechanism of the following: int function();
I don't understand the following phenomenon, could someone explain me please what I got
Can anyone please explain what the following two paragraphs mean, in simple english? (Taken
Can anyone please explain why the following will compile int a = aAssignments[i]->Count; int
The following statement is generating a compile-time error. int a=6/2(1+2); Can someone please explain
Could you please explain me the reason of the following situation. Today I wrote
A sample problem asks us to consider the code below and predict what will
Could someone please explain what is meant by the following ? You must define
Could somebody please explain what GCC is doing for this piece of code? What

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.