import java.util.Scanner;
public class Array {
public static void main(String[] args) {
float[] f=new float[5];
double [] d=new double[5];
System.out.println("给float数组赋值");
Scanner sc=new Scanner(System.in);
f[0]= new Float(sc.nextFloat());
f[1]= new Float(sc.nextFloat());
f[2]= new Float(sc.nextFloat());
f[3]= new Float(sc.nextFloat());
f[4]= new Float(sc.nextFloat());
System.out.println("遍历float数组");
for(float ff:f){
System.out.print(ff+"+++++");
}
System.out.println();
System.out.println("--------------------------------------------------------------------");
System.out.println("给double数组赋值");
Scanner sc1=new Scanner(System.in);
d[0]=new Double(sc1.nextDouble());
d[1]=new Double(sc1.nextDouble());
d[2]=new Double(sc1.nextDouble());
d[3]=new Double(sc1.nextDouble());
d[4]=new Double(sc1.nextDouble());
System.out.println("遍历double数组");
for(double dd:d){
System.out.print(dd+"+++++");
}
System.out.println();
System.out.println("--------------------------------------------------------------------");
System.out.println("填充float数组");
Scanner sc2=new Scanner(System.in);
f[0]= new Float(sc2.nextFloat());
for(int i=1;i
f[i]=f[0];
}
System.out.println("遍历float数组");
for(float ff:f){
System.out.print(ff+"+++++");
}
System.out.println();
System.out.println("--------------------------------------------------------------------");
System.out.println("填充double数组");
Scanner sc3=new Scanner(System.in);
d[0]=new Double(sc3.nextDouble());
for(int i=1;i
d[i]=d[0];
}
System.out.println("遍历doublet数组");
for(double dd:d){
System.out.print(dd+"+++++");
}
}
}
本回答被提问者和网友采纳