0

I am very very new to java and I'm trying to create the echo class found in UNIX in java. Basically, if I type in:

Echo 'i love you'

the command line prints

i love you

I have that part figured out, however, I can't seem to figure out the command line option -n which gets rid of the newline

I edited by code after reading the comment. However, it is still not doing what I hoped. My new code

The output of my new code As you can see, even after I enter the -n, the word is still on a newline

Nikolas Charalambidis
  • 40,893
  • 16
  • 117
  • 183
Lin0523
  • 171
  • 1
  • 1
  • 14

2 Answers2

2

In Java the array starts with 0. So the code should look like this>

if (args[0].equals("-n")

By the way, you should compare two strings with string.equals(..) method, not with the double equation operator.

Nikolas Charalambidis
  • 40,893
  • 16
  • 117
  • 183
1

The solution, as seen in the comments is to use System.out.print as opposed to System.out.println

bdavies6086
  • 382
  • 1
  • 5
  • 19