• 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

loop

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everybody
Consider the following code
public class Test1 {
static public void main(String args[])
{
System.out.println("Amit");
String a[]={"1","2","3","4"};
main(a);
}
}
what i observer for output is that it prints "Amit" for some specified time and then stops my question is isn,t this loop forms an endless cycle
regards
------------------
coffe drinker
 
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, you'll eventually get a StackOverloadException (i think that's what it's called) when you have too many function recursions. Or you'll run out of memory eventually.
 
amit mawkin
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks David for the reply
but isnt it true that it will pass/create string objects for the first time and wont create when it loops subsequent times
and i dont get any exceptions as stack overflow it simply just stops
regards.
------------------
coffee drinker
 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi amit,
well i am getting some exception and it doesnt simply come out as in ur case. NO system would behave like that. 'coz memory is limited regardless of languages.
regards,
maulin.
 
amit mawkin
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont know why no exception is thrown in my case
I am using win 2000 professional and jdk 1.3
but tell me how many String objects will be created in this case
and will the compiler create fresh string objects everytime
it loops
------------------
coffee drinker
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic