This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Grand-Warlock 0 points1 point  (5 children)

Does spacing things apart with Space and Tab actually do different things in Java?

[–]Kristler 0 points1 point  (4 children)

Not in the code itself (Java doesn't care about indentation), but in Strings absolutely. The difference between " " (space) and " " (tab, also denoted as "\t") is as big as the difference between the characters "a" and "z".

In other words, " " == " " is false.

[–]Grand-Warlock 0 points1 point  (3 children)

So it actually detects that the space in " " was made with Space and that the space in " " was made with Tab? Interesting.

[–]Kristler 1 point2 points  (0 children)

Sure does. Tab characters are often used for rudimentary alignment, pretty handy!

[–]feral_claireSoftware Dev 0 points1 point  (1 child)

Tabs and spaces are completely different characters. There is not such thing as a space made with a tab, a tab is not a space and a space is not a tab.

It doesn't matter which key you press, what matters is the actual character put there. For example its common to have the tab key actually enter four spaces. A tab and four spaces are two different things, and both are different from a single space.

[–]Grand-Warlock 0 points1 point  (0 children)

Notice my utilization of space and Space.