Java String


String one   = "hello";
String two = "world";
String three = "hello";
String four = new String("hello");
String five = "HELLO"
System.out.println(one==two); # false
System.out.println(one==three); # true
System.out.println(one==four); # false
# best to use this
System.out.println(one.equals(two)); # false
System.out.println(one.equals(three)); # true
System.out.println(one.equals(four)); # true
System.out.println(one.equalsIgnoreCase(five)); # true

String To Char Array

# string to char array
String hw = "hello world";
char[] ca = hw.toCharArray();
# print the array
for(char c:ch){

Char To ASCII Number

# convert char to ASCII number

Char To String

# char to string
char c = 'A';
String s = String.valueOf(c);

To Lower/Upper Case

String hw = "Hello World";

# to lower case
# to upper case


# substring params are start index, end index
String hw = "hello world";
System.out.println(hw.substring(6,7)); # w


String s = "hello world";
char[] ca = s.toCharArray();
ArrayList<String> al = new ArrayList<String>();
for(char c:ca){


String s = "the!quick@brown#fox$jumps%over^the&lazy dog";
String[] a = s.split("[!@#$%^& ]");
for(String z:a){

String To Integer

String s = "88";
int i = Integer.parseInt(s);




A software engineer, a rock climbing, inline skating enthusiast, a husband, a father.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How the right Hackathon formula can do wonders for your teams

Get from Point A to B safely with Tech for Good

Deploy Secure Landing Zone on Oracle Cloud Infrastructure

First Version of NFT in Dapp ☄️

Shopify App Development: Is It Possible to Build an E-commerce App in 24 Hours at Hackathon?

Differences in Full Stack, Backend, Front End Developers

Onboarding and performance

Spring Festival Campaign

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kevin FOO

Kevin FOO

A software engineer, a rock climbing, inline skating enthusiast, a husband, a father.

More from Medium

OOPs in Java

Basics of Java Programming

Digging into JAVA — Chapter 04

Variables methods and Objects

Java Naming Conventions