java string查找_查找输出程序(Java String类)

java string查找

Program 1

程序1

public class iHelp
{
	public static void main (String[] args)
	{
		System.out.println("Google".charAt(3));
	}
}

Output

输出量

    g

Explanation

说明

String.charAt() is a library function of String class, it returns character from given index of the string. Here, in the statement "Google".charAt(3) will return 'g', because 'g' exists on the 3rd index.

String.charAt()是String类的库函数,它从字符串的给定索引返回字符。 此处,在语句“ Google”中,charAt(3)将返回'g' ,因为'g'存在于第三个索引上。



Program 2

程序2

public class iHelp
{
	public static void main (String[] args)
	{
		System.out.println("Google"+3);
	}
}

Output

输出量

    Google3

Explanation

说明

In java String, "+" is a concatenation operator, if we concatenate any number or string with the string, it returns that number/string concatenated to the string.

在java字符串中, “ +”是连接运算符,如果我们将任何数字或字符串与字符串连接,它将返回连接到该字符串的数字/字符串。

Here, "Google" is a string and 3 is a number. The resultant string of "Google"+3 will be "Google3".

在这里, “ Google”是一个字符串,而3是一个数字。 结果字符串“ Google” +3将为“ Google3”



Program 3

程序3

public class iHelp
{
	public static void main (String[] args)
	{
		System.out.println(10+20);
	}
}

Output

输出量

    30

Explanation

说明

10+20 is a simple numeric expression, addition will be performed. Therefore, the result will be 30.

10 + 20是一个简单的数字表达式,将执行加法运算。 因此,结果将是30



Program 4

程序4

public class iHelp
{
	public static void main (String[] args)
	{
		if(System.out.println(10) == System.out.println(10))
			System.out.println("TRUE");
		else
			System.out.println("FALSE");
	}
}

Output

输出量

Compilation error:

编译错误:

    Main.java:6: error: 'void' type not allowed here
		    if(System.out.println(10) == System.out.println(10))
		                         ^
    1 error

Explanation

说明

The statement System.out.println() does not return anything. Therefore, no value will be for compression. Error will be "void" type not allowed here.

语句System.out.println()不返回任何内容。 因此,没有任何压缩值。 错误将是此处不允许的“ void”类型



Program 5

程序5

public class iHelp
{
	public static void main (String[] args)
	{
		System.out.println(10+20+""+40);
	}
}

Output

输出量

    3040

Explanation

说明

10+20 will be added first, and result of 10+20 will be 30. Then, " " will be concatenated to the 30, so it will become "30" in string. After that, "30"+40 will be "3040" (because if any string/number is added to the string it will concatenate as string).

10 + 20将被首先添加,以及10 + 20的结果将是30。然后,“”将被级联到30,所以它会成为字符串30”。 此后, “ 30” +40将为“ 3040” (因为如果在字符串中添加了任何字符串/数字,它将串联为字符串)。

Therefore, output will be "3040".

因此,输出将为“ 3040”



翻译自: https://www.includehelp.com/java/find-output-programs-java-string-class.aspx

java string查找

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值