Campbell Ritchie wrote:Yes, it does make a difference. Repeated concatenation in a loop runs in worse than On² time complexity. You won't notice anything for such a small String, not until you are concatenating at least 10⁴ instances. The problem remains today, even though an optimisation introduced in Java9 reduced the problem and made the process something from 10× to 100× faster than in Java8.
Tim Holloway wrote:And if you must concatenate by brute force, use a StringBuilder!
Liutauras Vilda wrote:
Swapnil Mishra wrote:That means constructors are only for Sub classes?
Monica. Shiralkar wrote:
Do we have to create object of Abc abc=new Abc() as class variable and then set the value as above or this object should be created inside the method and then value is set?
Edwin Torres wrote:You can use threads. In this example, a thread does the querying (simulated), sleeps 10 seconds, and repeats. The thread ends when you call interrupt(). Here's the code:
Duncan MacFarland wrote:I am trying to put a reference to a given subclass object into a linked list, and then come back later, and invoke a method of the subclass object that is in a given spot in the linked list. This produces an error because Object does not have that method. Is it necessary to cast the object to the correct subclass every time I want to use one of its methods, or is there a way to convince the JVM to treat it as always of type MySubclass? Thanks.
John Brendan wrote:Could you write me the code so I can test in Eclipse please?
Mark Do wrote:Ok.......I cant still seem to figure out how or where to put the for loop so that the whole array will loop 1024 times! someone help! thanks!