‫Hello, my friends, and welcome back.
‫In this tutorial we're going to learn about strings in Java.
‫Strings are a way to represent and manipulate sequences of characters such as letters, numbers and
‫symbols.
‫In Java, strings are objects from the Java.lang string class, which means they have a lot of built
‫in functionalities for working with text.
‫Let's start with creating the strings again, guys we are making and using the objects from string class.
‫So these variables or these data structures or data types are not primitive data types.
‫So strings are objects from classes.
‫Later on, when we talk about OP and object oriented programming, we'll understand what I mean by objects
‫and classes.
‫Creating the string.
‫To create a string, we start with capital S not small S because this is not a primitive data.
‫Okay, String say hello equal to Hello my friends.
‫String literals are sequences of characters enclosed in double quotes.
‫Java automatically creates a string object for you when you use string literals.
‫So this is the string keyword.
‫Starting with a capital S, Say Hello is the name of the string and the value of the string is.
‫Hello my friends enclosed between these two double quotes.
‫Now let's talk about how to print strings.
‫It's very simple.
‫We use system dot out dot print, and here we can use print or println.
‫Println will will print new line.
‫But I specify here.
‫Say hello, which is the name of the variable if we run the program.
‫We can get this message.
‫Hello, my friends.
‫Okay, so this is how we print the strings.
‫Let's move to another topic, which is the concatenation of strings.
‫You can combine multiple strings together using the concatenation operator, which is the plus sign.
‫Let's create another string.
‫I'll name it as my friends.
‫Oops.
‫Equal to.
‫My friends.
‫And I remove from here.
‫My friends, this is a string that says hello.
‫And this is the string that says, My friends.
‫I need to combine these two strings.
‫Okay, so how to do that?
‫I'll make system dot out dot print line and I'll start with say hello plus my friends.
‫So I'm combining.
‫I'm concatenating these two strings.
‫The hello and my friends.
‫Let me run and see.
‫And here is the result.
‫Hello, my friends.
‫And you can see that we printed out Say hello, which is Hello.
‫Only the concatenate concatenated strings.
‫Hello, my friend.
‫Another useful thing and functionality that we can use is the length of the string.
‫So you can find the length of the string using the length method included inside the string objects.
‫So.
‫I'll find here int.
‫L or length equal to.
‫I need to find the length of my friends.
‫String, my friends dot.
‫You can see we can access the string methods by putting the dot operator and you can see that there
‫is a method called length and it's returning type is integer.
‫If we go back and see int.
‫Is the returning type of the method.
‫Don't worry.
‫Later on we'll learn about methods and how to call methods.
‫But now focus with me on these topics.
‫My friends, I'm accessing the object, my friend, and I'm calling the method length in order to return
‫the length of the string.
‫If I need to print the length, I need to start with System.out.print.
‫And here I'll start with the length is and the concatenation operator is the plus sign and I am adding
‫here the length and I'm calling the variable.
‫Go and get the length value from the length variable.
‫This is the what I mean by the plus sign like this.
‫Don't please pay attention to this very important note.
‫If I start with length, it will give me an error.
‫Always start when using the system dot out dot print method always start with the.
‫Strings or if you want, if you don't need to make any string, just add empty double quotes like this.
‫Let me run.
‫And here we go.
‫We have the length is ten.
‫If we count the the number of letters in this string, my friends, we can see that it is ten.
‫Okay.
‫So it's useful function.