Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tab converted to spaces when using Scanner #77

Open
ciscoheat opened this issue Feb 15, 2016 · 2 comments
Open

Tab converted to spaces when using Scanner #77

ciscoheat opened this issue Feb 15, 2016 · 2 comments

Comments

@ciscoheat
Copy link
Contributor

{
  System.out.print("> ");
  Scanner newScanner = new Scanner(System.in);
  String s = newScanner.nextLine();
  System.out.print(s).print(", s.length()=").println(s.length())
}

Three tabs between 123 and 456 results in this:

___________________________________________________________
> 123            456
123            456, s.length()=18
@jcoplien
Copy link
Owner

What is the Java behavior on the same system?

@ciscoheat
Copy link
Contributor Author

I'm using Java 1.8 on Win 7, and the following program returns string length 9.

import java.util.*;

class HelloWorld
{
    public static void main (String[] args) throws java.lang.Exception
    {
        System.out.print("> ");
        Scanner newScanner = new Scanner(System.in);
        String s = newScanner.nextLine();
        System.out.print(s);
        System.out.print(", s.length()=");
        System.out.println(s.length());
    }
}
> 123                   456
123                     456, s.length()=9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants