In Java, char[]
, String
, StringBuffer
, and StringBuilder
are used to store, take, and return string data. One question that may come to your mind is, "What is the best way for defining a method to take string data and return string data in Java?"
We have four ways to take and return string data:
1) char[]
/byte[]
2) String
3) StringBuilder
4) StringBuffer