[JAVA]一维数组的创建, 初始化,访问修改数组元素,遍历数组
2021-05-13 18:31
标签:print out bsp 删除 nbsp odi 元素 string rgs 方法一: 方法二: 方法三: [JAVA]一维数组的创建, 初始化,访问修改数组元素,遍历数组 标签:print out bsp 删除 nbsp odi 元素 string rgs 原文地址:https://www.cnblogs.com/profesor/p/13127476.htmlString[] words = new String[] {"precarious", "exiguous", "prodigious"}; //注意new String[] 这里的[]必须是空的
String[] words = {"precarious", "exiguous", "prodigious"}; //可以把new String[]直接删除
String[] words = new String[3];
words[0] = "precarious";
words[1] = "exiguous";
words[2] = "prodigious";
public class a1d
{
public static void main(String[] args)
{
// String[] words = new String[] {"precarious", "exiguous", "prodigious"}; //注意new String[] 这里的[]必须是空的
String[] words = {"precarious", "exiguous", "prodigious"}; //可以把new String[]直接删除
// String[] words = new String[3];
// words[0] = "precarious";
// words[1] = "exiguous";
// words[2] = "prodigious";
System.out.println(words[1] + " earnings"); //访问数组元素
words[1] = "paucity"; //修改值
for (String word : words)
{
System.out.println(word);
}
}
}
文章标题:[JAVA]一维数组的创建, 初始化,访问修改数组元素,遍历数组
文章链接:http://soscw.com/essay/85266.html