Monthly Archives: February 2018

Java Ignore Case

String Str1 = new String(“This is really not immutable!!”); String Str2 = Str1; String Str3 = new String(“This is really not immutable!!”); String Str4 = new String(“This IS REALLY NOT IMMUTABLE!!”); boolean retVal; retVal = Str1.equals( Str2 ); System.out.println(“Returned Value … Continue reading

Posted in Compus | Tagged

Java Integrer to String Examples

  Convert using Integer.toString(int) The Integer class has a static method that returns a String object representing the specified int parameter. Using this is an efficient solution. Syntax public static String toString(int i) The argument i is converted and returned … Continue reading

Posted in Compus, General | Tagged

String types

2.1  String Literal vs. String Object As mentioned, there are two ways to construct a string: implicit construction by assigning a string literal or explicitly creating a String object via the new operator and constructor. For example, String s1 = “Hello”; … Continue reading

Posted in Compus | Tagged

Java convert String to Int

In Java, you can use Integer.parseInt() to convert a String to int. 1. Integer.parseInt() Examples Example to convert a String “10” to an primitive int. String number = “10”; int result = Integer.parseInt(number); System.out.println(result); Output 10 2. Integer.valueOf() Examples Alternatively, … Continue reading

Posted in Compus, General | Tagged