---
title: "Can anybody elaborate the difference between “Char” and “String” at Java"  
description: "Can anybody elaborate the difference between “Char” and “String” at Java"  
author: "Lady Bird Johnson"  
published: 2013-10-14  
updated: 2013-10-14  
canonical: https://www.mindstick.com/forum/1651/can-anybody-elaborate-the-difference-between-char-and-string-at-java  
category: "java"  
tags: ["java"]  
reading_time: 1 minute  

---

# Can anybody elaborate the difference between “Char” and “String” at Java

What is the [difference](https://www.mindstick.com/articles/157114/good-news-or-bad-news-and-the-difference-is) between the JDK6 java.util.regex.Pattern's "Boundary matchers" '\z' and '\Z'?

[Background](https://www.mindstick.com/articles/65/how-to-change-background-color-of-tab-control-in-c-sharp): I was [trying](https://answers.mindstick.com/qa/93698/6-mistakes-couples-are-trying-to-save-money) to read a UTF-8 encoded [file](https://www.mindstick.com/articles/59/encrypting-and-decrypting-files-using-c-sharp)'s contents into a [String](https://www.mindstick.com/articles/1527/string-split-in-c-sharp).

## Replies

### Reply by Kate Smith

The difference is anchor \Z matches the empty string just before the newline, while \z matches empty string after the newline.

## A very simple example to understand this is:

\

```
System.out.println("abc\n".matches("abc\\Z\\n"));   // true
System.out.println("abc\n".matches("abc\\z\\n"));   // false
System.out.println("abc\n".matches("abc\\n\\z"));   // true
```


---

Original Source: https://www.mindstick.com/forum/1651/can-anybody-elaborate-the-difference-between-char-and-string-at-java

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
