你如何比较一个带扫描仪的Arraylist [英] How do you compare an Arraylist w/ a scanner

查看:48
本文介绍了你如何比较一个带扫描仪的Arraylist的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。

需要一些帮助。我没理想如何开始这个。


我的arlist如下

静态ArrayList arlist;

arlist = new ArrayList< ;票>()


我不知道在这之后去哪里怎么比较一个值和类方法???即empid它不起作用,它告诉我,我不能因为它的静态


这是我到目前为止所拥有的

Hi Everyone.
Need some help. I have no ideal how to start this.

my arlist is as followed
static ArrayList arlist;
arlist = new ArrayList<ticket>()

I do not know where to go after this how do I compare a value with a class method??? ie empid it does not work, it tell me I can not because its static

Here is what I have so far

展开 | 选择 | Wrap | 行号

推荐答案

我不知道你在这里问的是什么,但是你创建自己的课程,如果你想能够比较两个对象的话你需要实现自己的比较器。我完全忘记了语法是什么。我认为你必须实现比较器或其他东西。希望其他人能够更好地解释它。
I''m not sure what you are asking here but anytime that you create your own class and if you want to be able to compare two objects of that class you will need to implement your own comparator. I forget exactly what the syntax is. I think you have to implements Comparator or something. Hopefully someone else will be able to explain it better.


这里你去:http://www.javapractices.com/Topic10.cjp
Here ya go: http://www.javapractices.com/Topic10.cjp


还有一点点失落。

我需要找到和学习的东西


是用来插入扫描仪的名字。

扫描仪然后创建一个新值,说ans。

,其中它是if else语句。

ans与一个值(即名称)进行比较不是静态的。

如果它在arraylist中找到它会打印它的名字

如果不是它会告诉你回到主菜单。

Still a little lose.
What I need to find and learn

is the use insert a name from a scanner.
the scanner then makes a new value say "ans".
in which it goes thou an if else statement.
ans is compared to a value (ie name) which is not static.
if it finds the name in the arraylist it will print it
if not it will tell you to go back to the main menu.

展开 | 选择 | Wrap | 行号


这篇关于你如何比较一个带扫描仪的Arraylist的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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