- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我最近一直在尝试学习 Java,虽然进展缓慢,但我已经成功了。不管怎样,我一直在读这本书:“Sams 在 24 小时内自学 Java”,并且很早就指出:
Java is flexible about where the square brackets are placed when an array is being created. You can put them after the variable name instead of the variable type, as in the following: String niceChild[];
To make arrays easier for humans to spot in your programs, you should stick to one style rather than switching back and forth. Programs that use arrays in this book always place the brackets after the variable or object type.
我完全理解所有这些,但后来在其中一个练习中,它似乎与刚才所说的相悖。正如您在下面看到的那样,它有: Stringphrase[] = { 但我不禁认为它应该是 String[]phrase = { ?我知道该程序可以很好地运行。我认为这只是一个错字,但我想从更了解它的人那里了解情况。
package com.java24hours;
class Wheel {
public static void main(String[] arguments) {
String phrase[] = {
"A STITCH IN TIME SAVES NINE",
"DON'T EAT YELLOW SNOW",
"JUST DO IT",
"EVERY GOOD BOY DOES FINE",
"I WANT MY MTV",
"I LIKE IKE",
"PLAY IT AGAIN, SAM",
"FROSTY THE SNOWMAN",
"ONE MORE FOR THE ROAD",
"HOME FIELD ADVANTAGE",
"VALENTINE'S DAY MASSACRE",
"GROVER CLEVELAND OHIO",
"SPAGHETTI WESTERN",
"AQUA TEEN HUNGER FORCE",
"IT'S A WONDERFUL LIFE"
};
int[] letterCount = new int[26];
for (int count = 0; count < phrase.length; count++) {
String current = phrase[count];
char[] letters = current.toCharArray();
for (int count2 = 0; count2 < letters.length; count2++) {
char lett = letters[count2];
if ( (lett >= 'A') & (lett <= 'Z') ) {
letterCount[lett - 'A']++;
}
}
}
for (char count = 'A'; count <= 'Z'; count++) {
System.out.print(count + ": " +
letterCount[count - 'A'] +
" ");
if (count == 'M') {
System.out.println();
}
}
System.out.println();
}
}
最佳答案
你实际上可以这样做:
String[] names = { "James", "Bond"};
//推荐这样做
String names[] = { "James", "Bond"};
//这是合法的,但可读性较差。
关于java - 这只是一个错字吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32586181/
我正在尝试在我的 Typo3 脚本中使用 FlexSlider 扩展 (1.50)。 FlexSlider 需要 jQuery,所以我通过扩展 T3 jQuery 添加了它。不幸的是,FlexSlid
我有两个表、两个模型和两个存储库。 部分 常见问题解答 常见问题属于部分(一个部分有很多常见问题)。这种关系是通过在 faq 中存储部分 uid 来完成的。 在我的模板中,我正在做:
作为it's mentioned on TYPO3 wiki ,我们可以使用 TypoScript 进行查询: page.60 = CONTENT page.60 { table = tt_co
我是一名优秀的程序员,十分优秀!