• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

about command line arguments

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
searching for an argument. if the one of the arg equals "test" should output its index,otherwise should print "-1"

Example: arg1 arg2 test ---> should prints "2" or arg1 arg2 arg3 should prints "-1".Of course it could be much more input.
My problem starts here... -1 -1 2 instead of just "2".As you can see before "2" it prints 2 times "-1".I think because of arg1 and arg2.really i cant get it. Maybe because of loops, but how?
 
Marshal
Posts: 76432
366
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nothing to do with command line arguments. It has to do with where you put the instruction to print −1. Work out where that instruction is and what the code around it is doing, and I think you will be able easily to solve your problem.
 
Saloon Keeper
Posts: 9562
79
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


**EDIT**
Or...
 
umit morris
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you both of you.I dont know sometimes i spend hours in one exercise.Sometimes two days later if i look i get it.is it good or bad, I Dont know really.
 
Sheriff
Posts: 17114
298
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, since we're already offering solutions, here's another one:

 
Campbell Ritchie
Marshal
Posts: 76432
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know I am a bit late, but let's try without using break;The Unicode escapes are:-
\u201c = “
\u201d = ”
\u2019 = ’
 
PI day is 3.14 (march 14th) and is also einstein's birthday. And this is merely a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic