snippetjavaMinor
Formatting small string use example
Viewed 0 times
formattingexamplesmallusestring
Problem
I am trying to format my code properly. I have already read the programming standards document and I believe that my code follows these rules. I have also used the CtrlShiftF keys in Eclipse which should format the code automatically.
Could someone tell me if this looks ok? It would be nice to get some feedback back and to see if it is being created automatically. I already know that the program does work. Any help would be great. If someone knows a better way to format the code, it would be great to hear it as well.
Could someone tell me if this looks ok? It would be nice to get some feedback back and to see if it is being created automatically. I already know that the program does work. Any help would be great. If someone knows a better way to format the code, it would be great to hear it as well.
public class UniString {
public static void main(String[] args) {
char[] det = { '\u20ac', '1', '1', '8' };
// char[]det is an array of characters.
for (char a : det) {
/*
* the for loop takes in the char values and prints them off in
* order the "det" array enters into the for loop through "det" ,
* goes into char a and can be written to the console through
* System.out.println(a).
*/
System.out.print(a);
}
System.out.println();
char[] name = { 'j', 'o', 'e' };
// This is another char array.
String nameString = new String(name);
/*
* The char array is made into a String by loading "name" into a String
* class
*/
String changeCase = nameString.toUpperCase();
/*
* The String "nameString" is changed to Upper case letters. The string
* is then stored as "caseChange".
*/
System.out.println(changeCase);
// "caseChange" is printed out.
}
}Solution
I think all the comments should be removed. The point of a comment is to explain why you wrote this code, not what the code does. If anyone reads the code, they will be able to understand what it does without reading the comments. When you write comments, always ask yourself : "Will this comment help me understand why I wrote this code 5 years ago?" (Or.. 2 weeks if you have a bad memory like mine), if you can't answer, you probably don't need comments!
The formatting looks perfect in my opinion.
The formatting looks perfect in my opinion.
Context
StackExchange Code Review Q#33081, answer score: 5
Revisions (0)
No revisions yet.