• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

assignment submitted to bill - java 1a(hundred)

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bill ,
Hi,
Thanx for replying, for my assignment java 1a(Hundred), there are some clarifications which I want.
try{
A try block is a lot of overhead. Is there another way you can do this?
> s = args[0];
> }catch(Exception e)
I had basically kept it there because in case a person forgets to enter a string while executing it should give a customized error... I am not sure if it can be done some other way.. any hints..
point 2:
for(int i=0; i<100; i++)<br /> > {
> System.out.print(s+" ");
100 String concatenations? Any room for optimization?
I am not concatenating the strings out here i am simply printing it hundred times after with a space.
any other suggestions..
[This message has been edited by Umesh Khosla (edited April 26, 2001).]
 
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The binary operator + used with strings does concatenation.
System.out.println( s + " " ) ; concatenates the space to the s string and then prints it.
Instead of try/catch you could use an if construct to check the args[].
Hope this helps.
 
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Umesh,
I assume (from your code) that you also got a ton of style-guide nitpicks?
(i.e. lots of "spacing...", etc.)
 
Umesh Khosla
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Style guide has really helped in cutting down on my regular silly mistakes , getting used to the new ways self study does not give u this kind of an insight. But the problem of indentation still persists the text message on which i paste my code usually corrupts everything , even though i have not used the tab key.
Tell me while submiiting the assignment on the assignment log can i use this medium without getting bashed up by the sheriff or should i just use the the regular email... and put a message to get myself included.
reply
    Bookmark Topic Watch Topic
  • New Topic