Java (not to be confused with JavaScript) is a class-based, object-oriented, strongly typed, reflective language and run-time environment (JRE). Java programs are compiled to byte-code and run in a virtual machine (JVM) enabling a "write once, run anywhere" (WORA) methodology.
-2
votes
0answers
13 views
Message on chat application is send only when server and client presses send button [on hold]
I've done a simple app in Java that sends a message using a port & socket. The problem is that whenever I press Send button, the app freeze and waits for clients to press the Send button in order ...
0
votes
0answers
33 views
Passing the name of a class to the UI
I've extended FragmentPagerAdapter but reading the example implementation automatically generated by Android Studio's "tabbed application" preset, ...
0
votes
0answers
9 views
Reuse URLs in a resource with jersey-spring 1.19
I'm working with jersey 1.19, the order resources detail depends of the order that I'm requiring:
...
6
votes
4answers
119 views
Generate valid random rgb color strings
I'd want to see if is possible to optimize performance even further of the following generate color method.
...
1
vote
0answers
23 views
AVL tree implementation
So I've just created an AVL tree in Java. However when I test its running time using the following code:
...
2
votes
1answer
18 views
Combat simulator - single page JavaScript with requirejs from a Java Applet
Single-page web app from Applet
I'm seeking feedback on my first single-page web app using requirejs and a web worker. I converted it from a Java applet, and the code is up on GitHub.
It's a combat ...
0
votes
0answers
19 views
Compressing a list of intervals [on hold]
I need to compress a list of intervals into a smaller list. Let me explain:
For example I have a list containing intervals [1,4],[2,5],[5,7],[10,11],[13,20],[19,21] and i want to join the intersecting ...
2
votes
4answers
70 views
Two integers start and end
Write a program that reads two integers start and end from the user
and prints the number from start to end inclusive. However, If end was
less than start than you should print them in ...
-2
votes
0answers
11 views
Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException Error [on hold]
I'm a newbie in Java and I'm trying to create a two player combat game in which the moves of the player are controlled by keyboard.As i didn't find any error in syntax or structure but it throws a ...
0
votes
2answers
49 views
Transforming CSS into an encoded representation
I have a java code that is supposed to format the content of a .css file so that I could use the result to make a enum class.
...
0
votes
0answers
9 views
Getting Runtime error NZEC in Java [on hold]
I am trying to solve this problem at Codechef. But I am getting a runtime error NZEC. Please help me in finding my mistakes. Here is my Java code.
...
-3
votes
0answers
29 views
Why does this code return 5 most of time, but returns 4 with a low probability? [on hold]
I have this piece of code which is trying to generate some independent items in parallel.
...
0
votes
0answers
18 views
Java application for downloading wallpapers
I'm fairly new to real world Java so I tried to rewrite an old app I wrote in vanilla java. I've made this one a lot more OO and used a dependency/build manager (Gradle). Now I just want to see what ...
-1
votes
0answers
8 views
How to display st.hasMoreTokens() in jTextArea according to category of tokens? [on hold]
I m working on scanner java program which read the java file and generate tokens according to category.I want this kind of output http://s11.postimg.org/y7d2x8j0j/ddd.jpg ,but my output ...
8
votes
1answer
62 views
Find/replace number with commas in Java
I have a requirement to put a comma between each digit of a number in a Java string.
Example input:
the number is 12345 and the number is 45678
The output ...
3
votes
1answer
25 views
Generic toString() for JPA base entity class
In a Java/JPA project I usually define a base class (on which I put the id). The goal is to implement an generic toString() on this base class (named BaseEntity) from which all other entities inherit. ...
6
votes
3answers
57 views
Text file manipulation with Java 8 and Guava
I am trying to do some translation of text files. I have a translation .csv file and a file I need to translate (tab delimited). The translation is creating a file with an extra column of the ...
2
votes
1answer
31 views
Three ways to read a number for a BitInputStream
I'm trying to learn how to write more readable code without introducing easily avoidable performance killers.
This is part of a BitInputStream Java class I'm ...
-3
votes
0answers
15 views
extJWNL synonym relation [on hold]
At the moment I'm trying to write a method which takes two "random" words and checks whether those words are related (synonym). The output should be a probability (0 to 1) how likely "word a" is a ...
1
vote
4answers
69 views
Java Rock/Paper/Scissors Game
For my computer science class I am tasked with writing a rock/paper/scissors game. I understand how to write the game, but I was wondering if someone more experienced than I could give me some ...
1
vote
0answers
11 views
Text box intuitive user-interaction using focus listeners
This code aims to replace labels used to explain a text box's container. This is done by adding a default string when the text box is considered empty to explain the purpose of the text box. However, ...
2
votes
0answers
26 views
Dice-rolling Android app
This is just a simple app. All it's suppose to do is move the dice around the screen when the user swipes up or down. It will move 2 dice (image drawables) to a position on the screen depending ...
4
votes
2answers
579 views
Simple FIFO and LIFO ferry simulator
I am trying to make a ferry simulator with one ferry that works like a stack and another like a queue. I have a working class for stacks and queues with pop/push; I am trying to figure out how to ...
11
votes
1answer
60 views
Options, options, options. None for JavaFX?
I was looking through the JavaFX library, and I spotted that JavaFX DOES NOT HAVE A JOptionPane EQUIVALENT. (Or at least not in my version - as @SirPython has said ...
2
votes
2answers
81 views
Non-Contiguous Substrings
Problem:
A non-contiguous substring of string \$s\$ is a sequence of \$k \geq 0\$ characters in \$s\$, in the order in which they occur in \$s\$. For instance, the set of all non-contiguous ...
-4
votes
0answers
12 views
0
votes
1answer
28 views
Null check when enabling Up navigation in Android
This upvoted SO answer and this upvoted SO answer both check for null in a similar way: they call a function in the if or assert ...
4
votes
1answer
42 views
Sieve of Eratosthenes Primes Efficiency
I'm fairly new to Java and was trying to make a program thats generates the primes from 2 - 100. I originally had a design of my own making but it was fairly inefficient so I did some research and ...
5
votes
1answer
37 views
Test whether target string is substring of source string
The code is self-explanatory. It has \$O(n)\$ complexity, and it tells whether a given string is the substring of the source string. Are there any cases where this algorithm fails? Is there anything ...
4
votes
2answers
55 views
Two string comparison
I wrote a function that finds the difference between two strings. This only works given that the difference is continuous.
Beyond doubt this already exists, I am recreating this for educational ...
2
votes
1answer
35 views
java.sql.Timestamps: There's gotta be an easier way
I have a function that counts how many "assists" a team performs during the course of their day. The way I've written it feels bulky and inefficient using GregorianCalendar.
Basically, the ...
1
vote
2answers
88 views
Determining if two strings are anagrams
Two strings are said to be anagrams of each other if the letters of
one string may be rearranged to make the other string. For example,
the words 'elvis' and 'lives' are anagrams.
In this ...
3
votes
2answers
102 views
Getting a list of all fields in an object
I've got the following code that I use to output a list of all (public) fields in an object in an easy(ish) to read way. The issue with it is that the code is not easy to look at, and I'm not sure ...
-4
votes
1answer
32 views
Getting a table on a date [on hold]
You and your date are trying to get a table at a restaurant. "you" is the stylishness of your clothes, in the range 0..10, and "date" is the stylishness of your date's clothes. The result getting the ...
4
votes
5answers
842 views
Two integers x & y
Given two int values, print whichever value is larger. However if the two values have the same remainder when divided by 5, then the print the smaller value. However, in all cases, if the two values ...
2
votes
3answers
62 views
Seasons by month and day
Write a program reads two integers representing a month and day and prints the season for that month and day. Assume that months are specified as an integer between 1 and 12 (1 for January, 2 for ...
4
votes
2answers
34 views
Speeding Up BufferedWriter
Are there any possible speed improvements I can make to the following method. It takes a JDBC ResultSet and breaks it into several CSV files:
...
0
votes
0answers
13 views
Pagination using JSTL
I created a JSP page with pagination using JSTL. The format is like this:
// if page 1 is active
1
// if records <= 10, display nothing more
//otherwise links to all other page numbers with "next"
...
2
votes
1answer
27 views
My own implementation of an hashtable
This is my own implementation of an hashtable. I would like to receive some reviews or some feedbacks.
...
6
votes
2answers
74 views
Sudoku game with varied difficulty level
I created a Sudoku game with varied difficulty level.
The Sudoku board creation process consist three stages:
Creation of an empty board
Filling the board with numbers
Making holes in the filled ...
2
votes
1answer
156 views
Check and clear last value
I have a method like this:
public boolean wasUserInactive() {
boolean result = userInactive;
userInactive = false;
return result;
}
This works, ...
0
votes
0answers
26 views
trying to make a Sudoku Solver with the recursive backtracking method [on hold]
I am a complete beginner, and Im just trying to learn general coding skills. I picked a sudoku solver as an intro project to get a grasp of java programming, but I cannot quite get it to work. Could ...
2
votes
2answers
64 views
Simple Java Tic-Tac-Toe game
About 2 weeks ago I made a Java game of Tic-Tac-Toe. It turned out great and it worked but it needed lots of help before it became a decent program. Since then, I have worked out lots of the kinks and ...
-3
votes
0answers
13 views
Bouncing ball program is not working [on hold]
In this bouncing ball program,when i call t.start() run method starts working as it prints value of x and y. but there is no change in position of ball. I have also called repaint() from run method. ...
6
votes
1answer
48 views
Live Graphical Demonstation of a Breadth-First Search Algorithm
As a first step to making a PacMan clone, I wrote a Breadth-First Search demonstration that updates itself live as you draw walls and drag around the start and end points. It was inspired by the site ...
6
votes
1answer
58 views
This LoginPane is a Pain
Well, it really isn't a big pain: but I fear of security risks (if that is even possible).
Background:
I decided to (sort of) abandon my Sudoku project (because I accidentally deleted it from disk), ...
4
votes
1answer
83 views
Read Twitter users from a text file
I have this code for reading Twitter users from a text file represented by integers in the format "int (space) int", where the first int is the ID of
the user doing ...
4
votes
1answer
59 views
Airline Reservations
I am looking for general feedback on this small, simple program I wrote. It works perfectly, but I am striving for readable, clean code. I also have specific questions:
(1) Is the 'switch' ...
0
votes
0answers
14 views
Count numbers that are in an interval [closed]
I'm new to Java and have to write code that asks the user for two numbers as an interval. Then the user must introduce n numbers and the program must return how many numbers belong to that interval.
...
3
votes
2answers
46 views
Find existing player to update or create new one
I'm making a game in Java 7, and I have this block of logic when handling an update from the server.
...