not a statement line:2
Please don't edit posts after they have been replied to. We now can't tell what the code is supposed to do; I am going to revert the edit.sai rama krishna wrote:. . . . I removed the external site link as you suggested
You probably already know you used a keyword in an incorrect context. Using new2 as an identifier name doesn't count as good coding style, however.sai rama krishna wrote:. . . please point me what mistake i made here
StringBuilder full stop. You should hardly ever have reason to use StringBuffer.sai rama krishna wrote:Thank you all. StringBuilder and StringBuffer right.
No, I would say temp is only slightly better.I shall let you work out the missing bits of code. They are all simple and easy to understand.. . . new2 not a good variable name probably temp is okay. . . .
There are three kinds of actuaries: those who can count, and those who can't.
That would make the solution more complicated than I was thinking of at first, so I suggest you stick with the else.Campbell Ritchie wrote:. . . You could simplify the control structure to get rid of the else and still have the program work correctly. . . .
sai rama krishna wrote:Above passed all tests but looks long. Any opportunity for refactoring or optimizing this code?
sai rama krishna wrote:For this challenge could not think of any helper methods though. May be finding length of str one helper method?
Maybe, and maybe not. Think again what helper methods you might like to use.sai rama krishna wrote:. . . May be finding length of str one helper method?
What about a method to tell whether the current char is 'x', or to return a one‑letter String depending on whether you do or don't have an 'x'?Liutauras Vilda wrote:. . . . Maybe there isn't really. . . .
At a first approximation, there is no difference. The simpler and more readable the code is, the better the JVM can optimise it. Remember that automatic tools can optimise code much better than programmers ever can, because the tools can “see” where the bottlenecks are at runtime.sai rama krishna wrote:. . . difference between readable and optimized/performance code . . .
There are three kinds of actuaries: those who can count, and those who can't.
You should use Streams. Get a copy of Java8 in Action or Modern Java in Action (different editions of the same book) by Urma Fusco and Mycroft (Manning) and go through that.sai rama krishna wrote:. . . May be i have not used it often enough
I have books with lots more pagessai rama krishna wrote:. . . 592 pages. . . .
Yes.Do you guys read books these days any more? . . .
Campbell Ritchie wrote:I think it is inelegant code because it is necessary to traverse the text thrice
There are three kinds of actuaries: those who can count, and those who can't.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |