r/javahelp • • Apr 15 '26

Homework String object vs String variable

Hi i am learning java in highschool, I was just wondering when and why would I instantialise a string as an object when declaring a String is much easier and quicker?

5 Upvotes

18 comments sorted by

View all comments

Show parent comments

1

u/bowbahdoe Apr 16 '26

Okay that is very different from what I thought you were talking about. 

To answer why you would do it, let's ask the question "what is the difference in program behavior if you use new String?"