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.

learn more… | top users | synonyms (2)

1
vote
3answers
358 views

Hex to Decimal converter

Any feedback is welcome: ...
-1
votes
0answers
23 views

Name-to-nickname map loaded from a data file: should I use a singleton or static field?

I have piece of code which converts name to nickname from given file. File looks like this: John,RamboJohn Brian,mystic George,bigG And piece of code which ...
4
votes
1answer
47 views

Get the tail of a file (the last 10 lines)

Print the tail of a file, if the file has less than 10 lines, then everything available is printed. Any suggestions for improvement are welcome. ...
2
votes
0answers
22 views

Spring configuration without XML is this reality?

We're doing a website for Cardshifter, and now I've converted the plain html files and css into a Spring MVC web application. Here is the typical configuration classes that I used in most of the ...
6
votes
1answer
45 views

Business program for a computer shop

Any advice would be great. I watched a few videos over the last 3 weeks and made a program up; what do you think? The program is a business ideal for a few computers in a shop, some computers with ...
2
votes
1answer
84 views

Get the first 10 lines of a file

Print the first 10 lines of a file, if it has less than 10 lines, print the whole file. Any suggestions on any kind of improvement are welcome. ...
11
votes
0answers
54 views

Numbers are high, numbers are low. Will you guess the right answer, though?

This question is a follow-up to: High-Low Guessing Game Now with shiny new graphics in JavaFX. You now have the awesome ability to choose which numbers to guess between. Now with Git Repository! ...
0
votes
1answer
40 views

Java class: for getOrder, getData, updateData operation

Problem Statement : Design a class for three operations for given set of integers : ...
1
vote
1answer
31 views

Simple LibGDX Pong game 2.0

I have been working on my Pong game and I added some nice new things to it. You can now select the difficulty on the start screen and I also added a pause screen. Also I gave the Pong ball a tail just ...
3
votes
3answers
877 views

Blackjack odds calculator

I'm working on getting switch and if statements down and I came up with this. It works well and I don't have any problems with it running properly. I was wondering if I could get some feedback on ...
3
votes
1answer
30 views

Generate and store hypernyms for all words in a hashmap

I have a system which reads in a clause in the form of a prolog "fact", i.e. 'is'('a sentence', 'this').. I want to generalize this up into higher-order classes and ...
10
votes
2answers
82 views

N-Queens functional

I'm trying to get a better grip on the new functional possibilities of Java 8. As an example, I took this very elegant Haskell snippet: ...
7
votes
1answer
97 views

The finest integers are palindromes

Challenge: Reverse the digits of a number and add it to the original until the number is a palindrome Specifications: Your program should accept as its first argument a path to a filename. ...
10
votes
3answers
636 views

Simple “secret message” decoder program

Since I am new to Java, I wanted to see if there were better ways of answering the same question. Are parts of my code redundant or maybe there's an easier way to get the same result? Problem J4: Big ...
1
vote
1answer
20 views

Solving the rod-cutting problem using dynamic programming

I've written what I believe is a valid dynamic programming solution to a variation of the rod cutting problem. In this problem, the goal is to make as few cuts as possible on a rod of length n. I ...
5
votes
1answer
44 views

TCP Client-Server communications

I have developed this simple TCP Server/Client communication program, and am looking for ways of lowering the code footprint where possible.Side note, Both Classes are Main as they run independently, ...
1
vote
1answer
28 views

Make a new design of Stack with a new function

I am doing some coding exercise, and I am not sure if I have met the requirement. Can someone help me to figure it out? How would you design a stack which, in addition to push and pop, also has a ...
-3
votes
0answers
22 views

Dividing a set of numbers in to two sets such that sum of elements in each set must be equal [on hold]

i have made a java program for following problem statement - "Dividing a set of numbers in to two sets such that sum of elements in each set must be equal " input: array of integers output: ...
4
votes
3answers
168 views

Plain old quick sort

Any suggestions for improvement are welcome. ...
3
votes
2answers
60 views

Immutable Queue in Java using an Immutable Stack

I am new to this Immutability concept and I have some coding experience in JAVA. Recently as a part of internship program, they gave me a 5-day task, which was to implement Immutable Queue. After some ...
5
votes
1answer
32 views

Regex to parse URIs for their correctness according to RFC 3986

I recently came to write a regex to parse URIs. Now I wonder, did I miss something? Did I make a mistake or could I have written it cleaner? That's why I'm here. In order to write the regex, I took ...
9
votes
1answer
63 views

Parsing log files of HearthStone: The log reading API

I'm still working on a parser that can parse log entries from a game called HearthStone, the overall idea is that it will read the log file live when the game is running, parses the log file and show ...
9
votes
3answers
474 views

Usage of StringBuilder for returning copies of a string

Given a string and a non-negative int n, we'll say that the front of the string is the first 3 chars, or whatever is there if the string is less than length 3. Return n copies of the front: ...
11
votes
2answers
308 views

Simple LibGDX Pong game

I created my first java game in LibGDX and it's working fine but I'm 100% sure a lot of my code can be written shorter than now. Does anyone have tips how I can make this code better? Like the ...
2
votes
1answer
46 views

Start of Login and Address book GUI in Java

In GUI that provided with the right username and password lets you open up an address book like GUI where you have crud like operations. I'm still very inexperienced with swing facilities especially ...
2
votes
2answers
58 views

Efficiency of calling other classes

After much trial and error, I finally came up with this code to call on other classes to perform their function. This code works and does what I want it to do, so I am looking for some comments on ...
5
votes
1answer
40 views

Self-made LinkedList and Node

I have recently made two kinds of linked lists in Java. I know that there is one with generic and one without. However, what I am really concerned about is which style should be used mostly (or which ...
0
votes
0answers
25 views

Program to continually read from and write to txt file [on hold]

This program is intended to meet the following requirements: Have 2 Classes, instantiated within main The first class needs to create/open a text file, find the last line and display the line-count. ...
2
votes
1answer
26 views

CREATE Service Call

I'm a relatively new (~6 mos) developer, and I'm hoping for some feedback on my code style/structure. While I'm particularly interested in efficiency and maintainability, I'm open to feedback ...
-1
votes
0answers
19 views

Merkle tree java implementation [on hold]

I am working on merkle tree implementation. I am just wondering whether I can request a code review here? Code is available here https://github.com/gomathi/merkle-tree
3
votes
4answers
79 views

Formatting MMyyyy to MMyy

The following is my sample code: String month = "09"; String year = "2014"; String monthYear = "092014"; The monthYear format is MMyyyy, I wish to format it to ...
11
votes
2answers
307 views

Add JPanel to JFrame

I just finished a fairly easy homework assignment. Basically all I had to do was add six JPanels that were just text boxes with color names as the text. However, ...
0
votes
0answers
13 views

Writing Fasta file to a list in Java. Reading the file returns null [on hold]

I am a novice programmer (I stopped coding for two years). I have been trying for a few days to fix this. The Database my lab was sent (I am an undergrad lab stuge) was screwed up the RNA and DNA data ...
-1
votes
0answers
59 views

Multiplying matrices [on hold]

When I create an array like this: double[][] twoDArrray = new double[2][5]; there are two ways to imagine the created array. This is the first way: ...
2
votes
1answer
33 views

SMS relay --> MySQL database

The main purpose of my program is to extract GPS information from text messages sent to several GSM modems send from various GPS tracking devices. The main flow of my program loops in three steps: ...
4
votes
2answers
70 views

Inefficient hash map operation provokes OutOfMemory: Java heap space error

I know I can increase the size of the heap but that seems like a poor solution. This program runs correctly on small files but when run on large data sets it crashes with the OutOfMemory: Java heap ...
7
votes
2answers
282 views

Quadratic Calculator

I am about a month into learning Java and I'm just looking for some comments on my code. Specifically, I would like to know if I'm being as efficient as I can be. This is the most complex thing I've ...
2
votes
1answer
53 views

TicTacToe in OOP

I'm trying to learn some OOP programming using Java, so I've created TicTacToe. Could you give me some advice on how I can improve this code? Player.java: ...
7
votes
2answers
141 views

Slide-Game in Swing

This was done as an assignment in school. As I am still learning some of the basic parts of Java be merciless when it comes to my code. As it is an assignment, some things are unchangeable. The ...
8
votes
1answer
87 views

Multiplying corresponding integers using streams

While reviewing Multiplying Lists, I got the impression that the problem was naturally suited to Java 8 streams. Unfortunately, since there is no convenient way to zip two streams, the solution ended ...
4
votes
1answer
43 views

Multiplying Lists

Challenge: Given 2 lists of positive integers. Write a program which multiplies corresponding elements in these lists Specifications: Your program should accept as its first argument a ...
5
votes
3answers
383 views

Does this Tic-Tac-Toe game follow abstraction and encapsulation?

This below program will be further enhanced for TicTacToe game with Human and Computer as players. Currently this program is written for choosing best move for a ...
3
votes
2answers
173 views

Determining if a pair exists in a large sorted array

I'm doing practice interview questions from here. Here is the one I am currently on - if you are given a very large sorted int array, then check of there exists a ...
4
votes
4answers
118 views

Finding Lottery odds - Topcoder #268

I have implemented the question #268 from Topcoder. The question is that there are 4 conditions for a lottery ticket: CHOICES - numbers available (10 ≤ CHOICES ≤ 100) BLANKS - number of numbers that ...
-2
votes
0answers
22 views
0
votes
0answers
18 views

Initializing final fields [closed]

I am wondering if there is any rule of thumb as for where to initialize private final fields in my class? Is it better if I do it in the class body before the constructor, e.g. ...
2
votes
3answers
378 views

Finding duplicates in two sorted arrays

This is an interview question from here. Specifically, the second asked for a function that took in two sorted arrays of integers with no duplicate values within a single array and which returned an ...
-1
votes
0answers
21 views

A library that will help Android Developers to work with Aspose Cloud APIs quickly and easily [closed]

AsposeCloudSDK makes it easy for Android app developers to work with Microsoft Word documents, Microsoft Excel spreadsheets, Microsoft PowerPoint presentations, Adobe PDFs, OpenDocument formats, ...
5
votes
1answer
54 views

Project Euler #10 in Java

Project Euler #10: The sum of the primes below 10 is \$2 + 3 + 5 + 7 = 17\$. Find the sum of all the primes below two million. My solution: ...
3
votes
2answers
52 views

Project Euler #7 in Java

Project Euler #7: By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number? Here is my solution: ...