• 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Need help with a code

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


So my problem is, that i need the second list to be optional, like, console asks if you want the second list or not, and i need it to always be one number, and i have no idea how.
 
Marshal
Posts: 76464
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch It is good to see correctly‑indented code.

Please give your classes proper names, not “sdsdd”.
Don't write new Integer(...). Simply write myList.add(k); The untime will automatically “box” that value to an Integer object.
What does line 29 mean? When is it possible for k to be negative? Why are you testing k in conjunction with the equality test? What is the condition controlling the else in line 32?
Do you mean you want to enter something from the keyboard and dependent on that entry you will execute or not execute the second half of the method? Have a look at this class; maybe this method will be useful.
But you shouldn't be executing half a method. That means the method is too long and should be divided up into something like this:-
 
Montana has cold dark nights. Perfect for the heat from incandescent light. Tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic