Tagged Questions
21
votes
4answers
2k views
Ternary operation in Java - Isn't this abuse?
I think that below code makes it difficult to understand and also I feel it's abuse of ternary operator in Java.
Code snippet:
String name = ...
5
votes
3answers
292 views
Printing braces
Question goes like this :
input: 1
output:
{}
input: 2
output:
{}{}
{{}}
input: 3
output:
{}{}{}
{{}}{}
{}{{}}
This is my program :
public class PrintBraces {
int n;
char []braces;
...
5
votes
1answer
104 views
Please review following code
Please review the following code. Methods getFirsts and getSeconds return a list of objects which implement CommonInterface and both of them are private. Is it a good or bad design.
@Override
public ...
5
votes
2answers
136 views
Need program cleaned up
I'm new to Java... I've been reading a java for dummies book and other ones too. I started building this program like a week ago. I'm sure it's very messy.. Just seeing if someone can clean it up and ...
4
votes
4answers
204 views
Command line Contact Management
Can you please review the following code and give any suggestions for improvment?
Class ContactList.java
import java.io.*;
import java.util.*;
public class ContactList {
public static void ...
4
votes
1answer
155 views
Indented if/else approach
I have a flow where if a certain condition is true then I should take another approach. That condition can be triggered by different scenarios. But each condition test must be done only if the last ...
4
votes
2answers
181 views
Request for help to tidy up number counting code
I am hoping someone can help me tidy up my code (for a practical for university). The practical is to use the random number generator to produce 100 integers (all between 1 and 10) and store them in ...
4
votes
2answers
165 views
How can I improve my code?
I just started Java programming yesterday (so don't expect too much), and I've written some code. My code works the way I want it to work, but there are obviously things wrong with it.
I was ...
4
votes
4answers
210 views
PMD code review violation
I have some doubts on code review tools violation
1) Most of the warnings in any code checking tools we get final
keyword could be used for any String used in a method. Is this
really required ...
3
votes
3answers
318 views
Clean up of a bunch of if-elses
Have the code below in a class I'm trying to clean up (written by someone else), and I'm trying to figure out if it's possible to simplify all the if else stuff going on here. Or at least make it ...
3
votes
3answers
146 views
Would like some feedback on code samples
I am currently in my 3rd year of a computer science course, I am looking into getting an internship over the summer but, I feel that my coding skills might be lacking for the workplace. Below, are ...
3
votes
5answers
285 views
Three edittext boxes: suggestions to clean up code
I am a newbie at writing Android apps and using Java in general. I have went through most of the Android hello view tutorials but still seem to be lacking some understanding of the basics. Here is a ...
3
votes
1answer
269 views
Is the code properly refactored or still some more improvements needs to be done?
I have got code here which I have tried to refactor on my own - but do any of you experts feel that it needs to be refactored more? What are the points should I cover? I would appreciate it if some ...
3
votes
2answers
228 views
How can I improve the quality of this code for better metrics
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import ...
3
votes
3answers
166 views
Beginner to OOP: Do these classes properly represent the objects in Java?
These classes are part of a program I am working on to convert Arabic numerals to Roman numerals and also the reverse. Do these classes look correct for representing objects in Java?
public class ...