Java is a popular programming language and runtime environment which allows programs to run unchanged on most platforms.
3
votes
2answers
44 views
Which of these two java class designs is better and why?
Example 1:
public interface Adder {
public int getSum();
}
public class AdderImpl implements Adder {
private int v1;
private int v2;
public AdderImpl(final int v1, final int v2) {
...
0
votes
0answers
32 views
re-arrange letters to produce a palindrome [closed]
I wrote this simple function (in Java) to re-arrange letters in a given String to produce a palindrome, or if it is not possible, just prints -1 and returns.
For some reason, I can't figure out why ...
0
votes
0answers
26 views
Using getters / setters in android
I want to find out if my coding structure was less efficient and much slower due to using getters and setters.
I have a few situations where I used them like follows
if(MyClass.getPicCount() >= ...
2
votes
3answers
100 views
Please help me clean up a lot of if else statements
Hello guys I'm new to Java programming. I'd like anyone here to help me clean up my code. It's about calculating men's risk of getting coronary heart disease. Here's the link to my method:
...
1
vote
3answers
65 views
improve this code for pattern
my aim is to design a function with arguments(int m,int n) so that output is like (for m=3,n=5)
3
34
345
34
3
i came up with this code
void func(int m,int n)
{
for(int i=1;i<n-m+2;i++)
{ ...
-1
votes
0answers
17 views
Using for loop to get the Hamming distance between 2 strings [closed]
So i'm having some trouble with this code. i need to get the Hamming distance (the Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols ...
-1
votes
1answer
27 views
Where should I use final(s) in these two specific codes? + few other questions [closed]
In our homework we been told to comment (//) on parameters before every method and describe what it receives and what it's supposed to do.
Another thing they asked is to use "finals" in the correct ...
0
votes
2answers
46 views
Selection sort java
Hello I am working on a program in which 10000 random no repeat numbers are selectively sorted into ascending order.
I have written the following code.
import java.util.Random;
public class ...
0
votes
0answers
8 views
How can improve my selective sort code [duplicate]
Hello I am working on a program in which 10000 random no repeat numbers are selectively sorted into ascending order.
I have written the following code.
import java.util.Random;
public class ...
1
vote
0answers
34 views
+50
API wrapper for Clojure, idiomatic style for libraries?
I wanted to wrap the jkeymaster library in a Clojure wrapper (for my own use, but perhaps also to save others some time). I'm just learning Clojure so I'm still not quite sure what "idiomatic ...
2
votes
2answers
54 views
Student Registration System Critique
The application is a "Student Registration System" using JDBC with Oracle as part of our school project. It works as it stands right now.
The questions are :
What is a better way to structure the ...
-2
votes
0answers
22 views
Writing a selection sort program? [closed]
Hello everyone in this program I am supposed to
1. Write a program name sorting.java that will use an array to store 10,000 randomly generated
numbers (ranging from 1 to 10,000 no repeat number)
2. ...
1
vote
0answers
19 views
AES-128 encryption class
This is the first time I've written a class in Java to do encryption using AES. Since security is involved I would love it if someone could take a look at it and let me know if anything is wrong with ...
1
vote
2answers
50 views
Encapsulating logging and throwing exceptions into a method. Bad practice?
original code example
if (var1 == null) {
String msg = "var 1 is null";
logger.log(msg);
throw new CustomException(msg);
}
if (var2 == null) {
String msg = "var 2 is null";
...
-2
votes
0answers
14 views
What is the best way to navigate android app(guidance/advice is needed) [closed]
Here is what I'm trying to achieve.(I'm an android noob, obviously)
I have a slide-menu on the left like in Facebook app.
When user clicks on a button in the menu what is the best way to ...