Narasimha Murthi has Published 23 Articles

Can I overload static methods in Java?

Narasimha Murthi

Narasimha Murthi

Updated on 30-Jul-2019 22:30:26

745 Views

Overloading is a one of the mechanisms to achieve polymorphism where, a class contains two methods with same name and different parameters.Whenever you call this method the method body will be bound with the method call based on the parameters.Example Live Demopublic class Calculator {    public int addition(int a , ... Read More

What is the difference between String, StringBuffer and StringBuilder classes in Java explain briefly?

Narasimha Murthi

Narasimha Murthi

Updated on 30-Jul-2019 22:30:26

462 Views

The String class of the java.lang package represents character strings. All string literals in Java programs, such as "abc", are implemented as instances of this class. Strings are constant, their values cannot be changed after they are created.The StringBuffer and StringBuilder classes are used when there is a necessity to ... Read More

How can I swap two strings without using a third variable in Java?

Narasimha Murthi

Narasimha Murthi

Updated on 30-Jul-2019 22:30:26

1K+ Views

To swap the contents of two strings (say s1 and s2) without the third.First of all concatenate the given two strings using the concatenation operator “+” and store in s1 (first string).s1 = s1+s2;The substring method of the String class is used to this method has two variants and returns ... Read More

Advertisements