扫描仪类混乱 [英] Scanner class confusion

查看:103
本文介绍了扫描仪类混乱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨所有

i从sun的网站上阅读扫描仪类文档,我想我会尝试编写一个程序来存储从用户到var输入的行,然后解析它在白色空间然后取决于新的字符串是什么我将做什么。我认为有一种比我想要的更简单的方法,但我只是想在我继续下一步之前让这些概念失效。我在循环条件中遇到不兼容的类型错误

hi all
i read the scanner class documentation from sun''s website and i thought i would have some fun trying to write a program that stores a line from the user to var input and then parses it on white space then depending on what the new string is i will do somthing. i think there is an easier way than what i am trying but i am just trying to get these concepts down before i move on to my next step. i am getting an incompatiable types error in my loop condition

展开 | 选择 | Wrap | 行号

推荐答案


嗨所有

i从sun的网站上阅读扫描仪类文档,我想我会尝试编写一个程序来存储从用户到var输入的一行然后在白色空间解析它,然后根据新字符串是什么我将做什么。我认为有一种比我想要的更简单的方法,但我只是想在我继续下一步之前让这些概念失效。我在循环条件中遇到不兼容的类型错误
hi all
i read the scanner class documentation from sun''s website and i thought i would have some fun trying to write a program that stores a line from the user to var input and then parses it on white space then depending on what the new string is i will do somthing. i think there is an easier way than what i am trying but i am just trying to get these concepts down before i move on to my next step. i am getting an incompatiable types error in my loop condition
展开 | 选择 | Wrap | 行号



你比较两个字符串的方式
The way you are comparing two strings
展开 | 选择 | Wrap | 行号



嗨!


即使你可以将字符串与等于-symbol进行比较,您的代码中会出错:为了进行比较,请始终使用 == 而不是 = 。第一个用于比较,第二个用于定义值。那不是你想要做的,是吗?因为那不会返回布尔值。


问候,

Nepomuk
Hi!

Even if you could compare Strings with the "equals"-symbol, there would be an error in your code: for comparison, always use == instead of =. The first is for comparing, the second for defining values. That''s not what you want to do here, is it? Because that will not return a boolean.

Greetings,
Nepomuk



你好,

即使使用 == 来比较字符串也不是一个好主意。有时它也会给你错误。始终使用equals(String str)方法来比较字符串:)

Hi,
Even using == for comparing strings is not a good idea. Sometimes it can give you errors also. Always use equals(String str) method to compare strings :)


这篇关于扫描仪类混乱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆