Tampilkan postingan dengan label String. Tampilkan semua postingan
Tampilkan postingan dengan label String. Tampilkan semua postingan

Rabu, 22 Juni 2016

It's quite common in day to day programming to join Strings e.g. if you have an array or List of String let's say {Sony, Apple, Google} and you want to join them by comma to produce another String "Sony, Apple, Google", there is not an easy way to do it in Java. You need to iterate through array or list and then use a StringBuilder to append a comma after each element and finally to remove the last comma because you don't want a comma after the last element. A JavaScript-like Array.join() method or join() method of Android's TextUtils class is what you need in this situation, but you won't find any of such method on String, StringBuffer, StringBuilder, Arrays, or Collections class until Java 8. Now, you have a class called StringJoiner which allows you to join multiple String by a delimiter.
Read more �

Kamis, 09 Juni 2016

This week's coding exercise is to remove duplicate characters from String in Java. For example, if given String is "aaaaaa" then output should be "a", because rest of the "a" are duplicates. Similarly, if the input is "abcd" then output should also be "abcd" because there is no duplicate character in this String. By the way, you can not use any third-party library or Java API method to solve this problem, you need to develop your own logic or algorithm and then write code to implement that algorithm. This is one of the interesting problems from Java coding interviews and you can use this program to weed out Java programmers who cannot write code. This problem is much better than Fizzbuzz because it requires more logic and coding than solving Fizzbuzz.
Read more �

Minggu, 07 Oktober 2012

10 Java String interviews Question answers
String interview questions in Java is one of Integral part of any Core Java or J2EE interviews. No one can deny the importance of String and how much it is used in any Java application irrespective of whether its core Java desktop application, web application, Enterprise application or Mobile application. The string is one of the fundamental of Java programming language and correct understanding of String class is a must for every Java programmer. What makes String interview questions in Java even more interesting is the special status of String in terms of features and privileges it has, like the + operator is kind of overloaded to perform String concatenation despite the fact that Java does not support operator overloading. There is a separate String pool to store String literal etc.
Read more �