---
title: "奇怪的String"
author: "aaronjiu_00"
date: "2008-12-09T12:06:12Z"
tags: ["Python", "虚拟机"]
categories: ["编程语言"]
slug: "string"
draft: false
lastmod: "2008-12-09T12:06:12Z"
id: 289319
url: "https://tonglin.iteye.com/blog/289319"
---

今天上午和同事讨论String的使用，众所周知，==比较两个字符串String的引用，equals比较两个字符串包含的值，那么大家看看，下面这几个的输出结果是什么样子呢？

```
	public static void main(String[] args) {
		String str = "hello";
		System.out.println(str == "hello");

		String str2 = new String("hello");
		System.out.println(str2 == "hello");

		String str3 = new String("hello");
		str3 = str3.intern();
		System.out.println(str3 == "hello");

	}
```

请大家给出运行结果，并给出为什么？