Arrays 当然没有这个方法了,白痴也知道啊 public void fill (boolean[],boolean){}你使劲添也白饶
呵呵,我觉得你这人真是搞笑,水平不高还嘴巴不干净。我告诉你我不算很菜的人,我英文和计算机底子都很好,java不过是我现在才学。Thinking in java你看过吗??如果你说Arrays里没这方法,那你就去跟BruceEckel报告他书里面的这个Bug吧!你看过java的API文档吗?写得情清楚楚java.util下有Arrays类,这下面又有Overloaded的各种fill()方法。 如果你比我还菜,上面的这段话就算我教你入门!
怎么搞的刚才白写那么长了,发丢了简单说一下 JAVA的内制对象不是OBJECT的子类,如:boolean,int,double,float所以这个方法不能生效 public void fill (Object[] o ){} 而这个方法却没有,所以,,,, public void fill (boolean[],boolean){}
你如果换成API中的任何一个类都会成功的 祝你玩的愉快
我实在没招了,不明白你说的意思,你还是仔细看看下面javaAPI文档的原文吧!static void fill(boolean[] a, boolean val) Assigns the specified boolean value to each element of the specified array of booleans. static void fill(boolean[] a, int fromIndex, int toIndex, boolean val) Assigns the specified boolean value to each element of the specified range of the specified array of booleans. static void fill(byte[] a, byte val) Assigns the specified byte value to each element of the specified array of bytes. static void fill(byte[] a, int fromIndex, int toIndex, byte val) Assigns the specified byte value to each element of the specified range of the specified array of bytes. static void fill(char[] a, char val) Assigns the specified char value to each element of the specified array of chars. static void fill(char[] a, int fromIndex, int toIndex, char val) Assigns the specified char value to each element of the specified range of the specified array of chars. static void fill(double[] a, double val) Assigns the specified double value to each element of the specified array of doubles. static void fill(double[] a, int fromIndex, int toIndex, double val) Assigns the specified double value to each element of the specified range of the specified array of doubles. static void fill(float[] a, float val) Assigns the specified float value to each element of the specified array of floats. static void fill(float[] a, int fromIndex, int toIndex, float val) Assigns the specified float value to each element of the specified range of the specified array of floats. static void fill(int[] a, int val) Assigns the specified int value to each element of the specified array of ints. static void fill(int[] a, int fromIndex, int toIndex, int val) Assigns the specified int value to each element of the specified range of the specified array of ints. static void fill(long[] a, int fromIndex, int toIndex, long val) Assigns the specified long value to each element of the specified range of the specified array of longs. static void fill(long[] a, long val) Assigns the specified long value to each element of the specified array of longs. static void fill(Object[] a, int fromIndex, int toIndex, Object val) Assigns the specified Object reference to each element of the specified range of the specified array of Objects. static void fill(Object[] a, Object val) Assigns the specified Object reference to each element of the specified array of Objects. static void fill(short[] a, int fromIndex, int toIndex, short val) Assigns the specified short value to each element of the specified range of the specified array of shorts. static void fill(short[] a, short val) Assigns the specified short value to each element of the specified array of shorts.
等一下,我刚才看了API,发现我是错的,,,,等等,我再看看
老大,这个我能运行import java.util.*;public class A { public static void main(String[] args) { int[] num = new int[5]; Arrays.fill(num,20);
CLASSPATH一般就不需要设置,除非你安装了JDBC驱动或别的要求设置CLASSPATH的。我也编译A.java成功了,我的CLASSPATH是:.;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msbase.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\mssqlserver.jar
// From 'Thinking in Java, 2nd ed.' by Bruce Eckel
// www.BruceEckel.com. See copyright notice in CopyRight.txt.
// Using Arrays.fill()
import com.bruceeckel.util.*;
import java.util.*;public class FillingArrays {
public static void main(String[] args) {
int size = 6;
// Or get the size from the command line:
if(args.length != 0)
size = Integer.parseInt(args[0]);
boolean[] a1 = new boolean[size];
byte[] a2 = new byte[size];
char[] a3 = new char[size];
short[] a4 = new short[size];
int[] a5 = new int[size];
long[] a6 = new long[size];
float[] a7 = new float[size];
double[] a8 = new double[size];
String[] a9 = new String[size];
Arrays.fill(a1, true);
Arrays2.print("a1 = ", a1);
Arrays.fill(a2, (byte)11);
Arrays2.print("a2 = ", a2);
Arrays.fill(a3, 'x');
Arrays2.print("a3 = ", a3);
Arrays.fill(a4, (short)17);
Arrays2.print("a4 = ", a4);
Arrays.fill(a5, 19);
Arrays2.print("a5 = ", a5);
Arrays.fill(a6, 23);
Arrays2.print("a6 = ", a6);
Arrays.fill(a7, 29);
Arrays2.print("a7 = ", a7);
Arrays.fill(a8, 47);
Arrays2.print("a8 = ", a8);
Arrays.fill(a9, "Hello");
Arrays2.print("a9 = ", a9);
// Manipulating ranges:
Arrays.fill(a9, 3, 5, "World");
Arrays2.print("a9 = ", a9);
}
} ///:~
而且既然我在编译我不在那目录下还能在哪??
public void fill (boolean[],boolean){}
//A.java
import java.util.*;public class A {
public static void main(String[] args) {
int[] num = new int[5];
Arrays.fill(num,20);
}
}
看看Arrays.fill()能不能过。就是这个问题,我编译这个程序的时候也是出错找不到fill()。
public void fill (boolean[],boolean){}你使劲添也白饶
如果你比我还菜,上面的这段话就算我教你入门!
public void fill (Object[] o ){}
而这个方法却没有,所以,,,,
public void fill (boolean[],boolean){}
祝你玩的愉快
Assigns the specified boolean value to each element of the specified array of booleans.
static void fill(boolean[] a, int fromIndex, int toIndex, boolean val)
Assigns the specified boolean value to each element of the specified range of the specified array of booleans.
static void fill(byte[] a, byte val)
Assigns the specified byte value to each element of the specified array of bytes.
static void fill(byte[] a, int fromIndex, int toIndex, byte val)
Assigns the specified byte value to each element of the specified range of the specified array of bytes.
static void fill(char[] a, char val)
Assigns the specified char value to each element of the specified array of chars.
static void fill(char[] a, int fromIndex, int toIndex, char val)
Assigns the specified char value to each element of the specified range of the specified array of chars.
static void fill(double[] a, double val)
Assigns the specified double value to each element of the specified array of doubles.
static void fill(double[] a, int fromIndex, int toIndex, double val)
Assigns the specified double value to each element of the specified range of the specified array of doubles.
static void fill(float[] a, float val)
Assigns the specified float value to each element of the specified array of floats.
static void fill(float[] a, int fromIndex, int toIndex, float val)
Assigns the specified float value to each element of the specified range of the specified array of floats.
static void fill(int[] a, int val)
Assigns the specified int value to each element of the specified array of ints.
static void fill(int[] a, int fromIndex, int toIndex, int val)
Assigns the specified int value to each element of the specified range of the specified array of ints.
static void fill(long[] a, int fromIndex, int toIndex, long val)
Assigns the specified long value to each element of the specified range of the specified array of longs.
static void fill(long[] a, long val)
Assigns the specified long value to each element of the specified array of longs.
static void fill(Object[] a, int fromIndex, int toIndex, Object val)
Assigns the specified Object reference to each element of the specified range of the specified array of Objects.
static void fill(Object[] a, Object val)
Assigns the specified Object reference to each element of the specified array of Objects.
static void fill(short[] a, int fromIndex, int toIndex, short val)
Assigns the specified short value to each element of the specified range of the specified array of shorts.
static void fill(short[] a, short val)
Assigns the specified short value to each element of the specified array of shorts.
public static void main(String[] args) {
int[] num = new int[5];
Arrays.fill(num,20);
}
}
.;d:\program files\jdk\bin;d:\program files\jdk\lib;d:\program files\jdk\jre;e:\j2se_doc\thinking in java\codeJcreator中classpath定义如下:
D:\Program Files\jdk\jre\lib\rt.jar;
D:\Program Files\jdk\lib\dt.jar;
D:\Program Files\jdk\lib\tools.jar;
D:\Program Files\jdk\jre\lib\ext\dnsns.jar;
D:\Program Files\jdk\jre\lib\ext\ldapsec.jar;
D:\Program Files\jdk\jre\lib\ext\localedata.jar;
D:\Program Files\jdk\jre\lib\ext\sunjce_provider.jar;
D:\Program Files\jdk\bin;
D:\Program Files\jdk\lib但是我无论是用Jcreator还是本身的javac都不能编译成功,各位看一下是什么问题,谢谢!
import java.util.*;public class A {
public static void main(String[] args) {
System.out.println(new Date());
}
}
可以成功Date这个类也是在java.util下啊!跟Arrays在同一层目录。
classpath=
.;d:\program files\jdk\bin;d:\program files\jdk\lib;d:\program files\jdk\jre;e:\j2se_doc\thinking in java\codeclasspath中放的应该是jar文件或是包含class文件的文件夹
放d:\program files\jdk\bin没有意义还有这个:d:\program files\jdk\lib应该指定到具体的jar 文件
问题的根源确实是同名类的存在!!!我把classpath设回到之前通过不了的情况,既加入d:\program files\jdk\bin后,按你的方法在Arrays.fill()前加上java.util.成功了!原来编译器先去找classpath里面的东西在bin目录下发现了同名类Arrays!呵呵,是我之前写的一个程序放到里面了,过了太久没注意这问题,然后我把那程序删了,再编译,就找正确了!非常感谢!!!