Char Arrays [英] Char Arrays

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

问题描述

我是Java的新手,我被分配了一个项目,需要将用户的输入作为char数组,并返回数组的长度,返回数组中的值,将数组复制到一个新对象(不使用clone();),连接数组,并查找数组是否是原始数据的子字符串。


我正在使用blueJ我遇到的第一个问题是我无法弄清楚输入格式,即当我创建一个新对象时,它会询问int length和char值,但是如果我把''a'', b,c代表char值,它有错误,与''a''+''b''+''c''相同,以及我能想到的任何其他东西。对自己的作品''a''。有一次我确实得到了超过1个字符,但它返回了一堆符号。


任何熟悉BlueJ的人?谢谢

I am a complete newbie at Java, and I''ve been assigned a project which needs to take a user''s input as a char array, and return the length of the array, return the values in the array, copy the array to a new object (without using clone(); ), concatenate the array, and find whether an array is a subString of the original.

I''m using blueJ, and the first problem I''m having is that I can''t figure out the input format, ie when I create a new object, it asks for int length and char value, but if i put ''a'',''b'',''c'' for char value, it has error, same with ''a''+''b''+''c'' and any other thing I can think of. ''a'' on its own works. At one point I did get to put in more than 1 char, but it returned a bunch of symbols.

Any one familiar with BlueJ? Thanks

推荐答案

您是否可以在不使用blueJ的情况下编写程序?你知道System.In吗?
Are you able to write the program without using blueJ? Do you know about System.In?


阅读java.util.Scanner类。
Read about the java.util.Scanner class.



任何熟悉BlueJ的人?
Any one familiar with BlueJ?



顺便说一句,BlueJ只是一个IDE,而不是Java。如果它可以在Java(从命令行)工作,它应该在任何IDE中工作,无论它是BlueJ,Eclipse,Netbeans还是其他任何东西。如果它在IDE中工作,它也应该没有工作。


如r0所说,检查扫描仪类。它允许通过各种类型的输入做很多非常整洁的事情。


问候,

Nepomuk

By the way, BlueJ is just an IDE, not Java. If it will work in Java (from command line), it should work in any IDE, no matter if it''s BlueJ, Eclipse, Netbeans or anything else. And if it works in an IDE, it should also work without.

As r0 said, check the Scanner class. It allows to do many very neat things with various types of input.

Greetings,
Nepomuk


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

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