字符串面试题:以下程序的输出结果是
来源:互联网 发布:网络不通怎么解决 编辑:程序博客网 时间:2024/04/27 18:50
import java.util.*;
/**
* Description:
* <br/>网站: <a href="http://www.crazyit.org">疯狂Java联盟</a>
* <br/>Copyright (C), 2001-2016, Yeeku.H.Lee
* <br/>This program is protected by copyright laws.
* <br/>Program Name:
* <br/>Date:
* @author Yeeku.H.Lee kongyeeku@163.com
* @version 1.0
*/
public class DiamondTest
{
public static void main(String[] args)
{
String s = "hello";
String t ="hello";
String str = "hello";
char c[] ={'h','e','l','l','o'};
char ch[] =str.toCharArray();
if(ch==c)
System.out.println("true");
else
System.out.println("false");
if(ch.equals(c))
System.out.println("true");
else
System.out.println("false");
String s2 = new String(c);
if(s2==(s))
System.out.println("true");
else
System.out.println("false");
if(s2.equals(s))
System.out.println("true");
else
System.out.println("false");
}
/**
* Description:
* <br/>网站: <a href="http://www.crazyit.org">疯狂Java联盟</a>
* <br/>Copyright (C), 2001-2016, Yeeku.H.Lee
* <br/>This program is protected by copyright laws.
* <br/>Program Name:
* <br/>Date:
* @author Yeeku.H.Lee kongyeeku@163.com
* @version 1.0
*/
public class DiamondTest
{
public static void main(String[] args)
{
String s = "hello";
String t ="hello";
String str = "hello";
char c[] ={'h','e','l','l','o'};
char ch[] =str.toCharArray();
if(ch==c)
System.out.println("true");
else
System.out.println("false");
if(ch.equals(c))
System.out.println("true");
else
System.out.println("false");
String s2 = new String(c);
if(s2==(s))
System.out.println("true");
else
System.out.println("false");
if(s2.equals(s))
System.out.println("true");
else
System.out.println("false");
}
}
output:
false
false
false
true
------------------------------------------------------------------StringBuffer面试题------------------------------------------------------------------
public class DiamondTest
{
public static void main(String[] args)
{
StringBuffer a = new StringBuffer("A");
StringBuffer b = new StringBuffer("B");
operate(a,b);
System.out.println(a+","+b);
}
static void operate(StringBuffer x,StringBuffer y)
{
x.append(y);
y=x;
}
}
输出结果:AB,B
0 0
- 字符串面试题:以下程序的输出结果是
- 面试题:以下程序的输出结果是
- 面试题:以下程序的输出结果是什么?
- 面试题 以下程序的输出结果是什么
- java集合类面试题以下程序的输出结果是什么
- 以下程序输出结果是____。
- 以下代码的输出结果是什么?
- 面试例题2:以下代码的运行结果是 。[Advantech2005年12月面试题]
- 下面程序的输出结果是多少?
- java面试题的字符串逆序输出
- 面试题:字符串倒序输出
- 下面程序输出结果是多少?
- 以下是腾讯的笔试面试题:
- 百度面试题 字符串的全排列输出
- 【JavaScript】面试题:重复输出一个给定的字符串
- JavaScript 面试题:重复输出一个给定的字符串
- Java面试题:输出字符串的所有组合
- java面试题:输出字符串每个字母出现的次数
- java中Keytool的使用总结
- Java使用Axis调用WebService
- Hibernate 多对多关系映射详解
- Android截屏浅析
- crontab 命令详解
- 字符串面试题:以下程序的输出结果是
- UIScrollView上部空白的问题
- IOS小菜鸟养成记00
- 是什么能够两小时写出《flppybird》游戏
- 11g RAC完全安装图解(VM Workstation8.0+Centos5.5)02-Oracle安装
- 用 Python 和 OpenCV 检测图片上的条形码
- 黑马程序员_面向对象(二)
- Could not find the main class: org.apache.catalina.startup.Boostrap. Program will exit
- Android开发之浅谈内容提供者provider的使用