# String equality and operators

## Concatenation:  + and +=

![](https://3494582050-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LSemf7mp1liQa7nfIAC%2F-LTbOgP4UpnyBK4OY9pZ%2F-LTbV7KHWQ5XGwedadyh%2Fimage.png?alt=media\&token=f0f27dec-7100-4461-a033-f98b6ec006d1)

![](https://3494582050-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LSemf7mp1liQa7nfIAC%2F-LTbOgP4UpnyBK4OY9pZ%2F-LTbVBQhjEyJ_Jz39qWS%2Fimage.png?alt=media\&token=174b1bc3-edf9-432f-91e0-d75a6230449a)

![](https://3494582050-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LSemf7mp1liQa7nfIAC%2F-LTbOgP4UpnyBK4OY9pZ%2F-LTbVLCYKukebsH8p9Gn%2Fimage.png?alt=media\&token=0478a2ff-2f3e-4d0a-a33b-4e67676d602f)

![](https://3494582050-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LSemf7mp1liQa7nfIAC%2F-LTbOgP4UpnyBK4OY9pZ%2F-LTbVQ23FuBPmE_tlyrC%2Fimage.png?alt=media\&token=70cfea90-b33b-4e51-846a-6884668ad2b1)

```java
package com.test.test1;
public class StringMethods {
	public static void main(String[] args) {
		String day = "OCJA" + "Cert" + "Exam";
		System.out.println(day);
	}
}
```

```java
package com.test.test1;
public class StringMethods {
	public static void main(String[] args) {
		int num = 10;
		int val = 12	;
		String aStr = "OCJA";
		String anotherStr = num + val + aStr;
		System.out.println(anotherStr);
	}
}
```

```java
package com.test.test1;
public class StringMethods {
	public static void main(String[] args) {
		int num = 10;
		int val = 12;
		String aStr = "OCJA";
		String anotherStr = "" + num + val + aStr;
		System.out.println(anotherStr);
	}
}
```

![](https://3494582050-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LSemf7mp1liQa7nfIAC%2F-LTbOgP4UpnyBK4OY9pZ%2F-LTbWZoNt1i3G2w2AXxP%2Fimage.png?alt=media\&token=c837dc41-1690-4e4b-8999-9daa2e936fe5)

![](https://3494582050-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LSemf7mp1liQa7nfIAC%2F-LTbOgP4UpnyBK4OY9pZ%2F-LTbWxP86C7_0iHo5J-d%2Fimage.png?alt=media\&token=94df0b11-e6b7-436b-9837-c7f1072822d3)

```java
package com.test.test1;
public class StringMethods {
	public static void main(String[] args) {
		String lang = "Java";
		lang += " is everywhere!";
		String initializedToNull = null;
		initializedToNull += "Java";
		System.out.println(initializedToNull);
	}
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gyansetu-java.gitbook.io/core-java/string/string-equality-and-operators.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
