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)

0
votes
1answer
7 views

is my add method in binary search tree correct

I want to implement code for inserting a new Node in a binary search tree in java so please check if my code is correct ,,, Here is my method : ...
0
votes
0answers
7 views

Logic for shuffling sliding puzzle

i'm working on a sliding puzzle, one little project as a hobbie, and yesterday i thought that instead of working on an algorithm to figure out a solved puzzle, it would be easier to make an algorithm ...
7
votes
2answers
198 views

Java Singly Linked List Implementation

I've implemented a singly linked list in Java as a practice exercise and would appreciate a review. LinkedList.java ...
1
vote
0answers
13 views

Java web scraping robots

I am developing application that goes through 2 websites and gets all the articles, but my code is identical in most parts, is there a way to optimize this code actually :/ (TL and DN are the naming ...
2
votes
1answer
16 views

Printing the minuend and subtrahend in a Minimum Difference algorithm

I have a Minimum Difference algorithm, and I wanted to expand on it by printing the actual elements that were subtracted. I'm just wanting to know if this is the best way to do it. ...
0
votes
1answer
19 views

Simplifying LZW compression & decompression

I have wrote code that takes an input file text that can be compressed, and should contain ascii values, and then a new file is created with an appended ".lzw" and that file can then be decompressed. ...
8
votes
3answers
580 views

Student/Class Project Java MySQL

I have a Java application that uses a few switch statements to get user information about students and classes. I have three MySQL tables: students ...
-2
votes
1answer
41 views

Reading a file byte by byte in Java [on hold]

I am currently using this: Path path = Paths.get("c:\test\test.txt"); byte[] all= Files.readAllBytes(path); The problem with this is that I have to load the ...
1
vote
2answers
73 views

Instantiating shapes using the Factory Design Pattern in Java

Trying to learn the factory design pattern, came up with some code based on a Shape Factory (found this example here). Is this the right way to implement the factory pattern? ...
0
votes
0answers
17 views

Java 8: effective usage of Optional and Function [on hold]

I've wrote the following constructor: ...
0
votes
0answers
13 views

Correct use of SettableListenableFuture?

For the code below, is there any advantage of returning the SettableListenableFuture rather than the ...
0
votes
0answers
22 views

Refactoring Java Method into smaller methods [on hold]

I have a Java application that uses a few switch statements to get user information about students and classes. I have three MySQL tables: students student_id | student_name | hometown classes ...
2
votes
2answers
33 views

Parallel integer Quicksort in Java

Now I have that parallel Quicksort for (primitive) integer arrays. ParallelIntQuicksort.java: ...
3
votes
1answer
173 views

Method to replace all spaces in a String with '%20'

Problem statement (extracted from cracking the coding interview): Write a method to replace all spaces in a string with'%20'. You may assume that the string has sufficient space at the end of the ...
-2
votes
0answers
12 views

Getting Non zero exit code error while submitting code [on hold]

Solution given below is giving NZEC on spoj online judge Summary of problem: In the question we are to find the number of possible path from s to t in a directed acyclic graph. My approach is take a ...
3
votes
0answers
52 views

Tic Tac Toe - Stage 2: console PvP + PvE + “EvE”

A while back I had opened this topic: Tic Tac Toe - Stage 1: console PvP I had to put that mini-project on hold due to exams, but I've started working on it again a couple of days ago. Now it's ...
3
votes
1answer
54 views

Faster QuickSort

I'm trying to make my QuickSort faster than it is and I have got no more ideas about how to make it more efficient for all types of arrays but mostly very big arrays. It uses random to create the ...
2
votes
0answers
27 views

Interface modelling for a journaling program in Java

My program's Journal consists of unique Pages identified by their Day. Within those pages ...
-3
votes
0answers
18 views

Merge code for text slide and text randomising when page is refreshed [on hold]

Hi i'm struggling to put two codes together what will randomize the information every time page is refreshed. Also while someone is one the page, i'm wanting the change to different text.. i need this ...
3
votes
1answer
40 views

Number-guessing game with betting

I'm really new to programming, currently following several tutorials and guidelines. After a couple of days of studying, I've learnt the basics of Java and conditionals and took on my first program. ...
0
votes
0answers
27 views
0
votes
1answer
36 views

Longest contiguous Increasing Subset in java

I have tried to come up with a solution to the longest increasing subsequence problem.Can this solution be optimized further? Example 1: Input: {5,4,3,7,8,9,11} Output: 3, 7, 8, 9, 11 Example 2: ...
-5
votes
0answers
19 views

What is a good way to fix my logic [on hold]

I have to write a code that converts infix to postfix. I am having trouble sorting out the logic to do so. Here is my current code: ...
2
votes
2answers
73 views

My spaceship is slow to explode after being hit by the asteroid

I am making a game for my computer science class. My professor's requirements are: Write a Processing program that draws a triangle in the middle of the window. Rotate the triangle when the left and ...
1
vote
1answer
25 views

Retrieving access token from SharedPreference

Here is code that retrieves an access token from SharedPreference. ...
4
votes
1answer
317 views

Time limit exceeded for java “insertion sort linked list”

I was working on LeetCode to practice myself with Java programming. I encountered a question about insertion sort a linked list. My code currently runs correctly, but it failed on an instance with ...
-1
votes
0answers
26 views

Data Migration in Java [on hold]

I'm currently doing a small data migration. I need to connect to SAP to get some data, make some modification, and then insert it into our DB. I've written some java code which would help me ...
2
votes
0answers
33 views

Application for encrypting and decrypting files in Java - follow-up

(Everything needed for running the app is here.) I have refactored my previous version a bit. App.java: ...
5
votes
3answers
332 views

Parsing a complex number using regular expressions

Requirements were to create a constructor for a complex number, that receives a string. For example: \$3+5i\$. The regex extracts positive or negative numbers from the string with optional decimal. ...
1
vote
0answers
49 views

Email text parser

I am writing a parser to parse out the fields of an email message in the following format (note that I expect that the "To:" field could contain multiple lines, same with the "Subject:" field. ...
3
votes
2answers
46 views

Finding duplicates in given list of files

I implemented a simple tool to find duplicate files, by applying the following strategy: Take a list of files and return the sets of duplicates (set of sets) Implement a custom ...
5
votes
1answer
50 views

Given a monetary amount, calculate the equivalent change

I have written a program that takes in some amount of money, and prints the equivalent change (starting at hundred dollars, to fifty, to twenty, down the pennies). Here is the code: ...
1
vote
0answers
16 views

alternatives solutions to the problem of trying to find a substring within a string using Regular Expression

I'm new to Java and is trying to find a substring within a string using Regular Expression . Below is the code I have came up with. However, I was just wondering if there are any alternative ways to ...
2
votes
0answers
22 views

Pagination links for various lists using Spring-HATEOAS

I'm using Spring HATEOAS to create some links on my REST API. However, the entities i'm returning are very close, so the code to generate the links are the same: ...
2
votes
2answers
44 views

Program looks for correct balance of ( [ and { in expression

I'm still new to programming. (First exposure was school about a year ago), and for some reason this problem really gave me a lot of problems trying to solve it. Can you help me understand what I ...
3
votes
1answer
47 views

Application for encrypting and decrypting files in Java

(See the next iteration.) I have that application for en-/decrypting files. Here, I will post the actual GUI and command line code. In order to run the program refer to this GitHub repository. Some ...
5
votes
2answers
55 views

Tracking Containers in a Train Station

This is a time line for control over the events of some containers in a train station. It gets all the data to build the time line by getting a JSON from a database via REST service. The app resets ...
4
votes
2answers
75 views

DoublingQueue in Java

Inspired by this CR question, I decided to create my own queue! If you guys see anything taboo or have any improvements, please let me know. Ultimately I want it to be feature rich and bug free, with ...
2
votes
1answer
27 views

An asynchronous service to produce a results cache for a list of items

What I've created is a CacheBuilder service that will be passed in a list of items, and will build a results cache. The results are produced by making calls to ...
2
votes
1answer
73 views

Java Tree Implementation

I wrote a simple tree data type in Java consisting of nodes which are themselves trees, and where each tree has its own list of children (not a binary tree). I plan on eventually using it in a minimax ...
3
votes
0answers
43 views

Expression parser using Shunting-yard algorithm

I've been working on a expression parser which will be part of another project (some sort of DSL). This parser basically uses the Shunting-yard algorithm, except for the case of parenthesis: here it ...
9
votes
1answer
605 views

Simple one heap Nim game, OOP exercise

I wrote this game to practice some simple OOP. You play against the computer, but be aware that the computer has no real AI, as it just generates its moves randomly. The loser is the one whose turn it ...
1
vote
1answer
50 views

Web Page Inspector

I wrote a small JavaFX Application to inspect Javascript within HTML pages. It loads and browses sites, shows the HTML source, shows an overview of the text of a page, provides a simple Javascript ...
2
votes
1answer
55 views

Two Java methods for easy writing and reading bytes in files

I have these easy-to-use methods for reading and writing binary data in files. FileTools.java: ...
11
votes
5answers
524 views

FiniteArrayQueue type with interface and unit tests

Doing some exercises on basic data structures, I learned about queues, and decided to roll my own to better understand how a basic queue can function. As the name indicates, this Queue is made from a ...
0
votes
1answer
41 views

Using Scanner.nextInt() whilst ignoring rest of line

I'm contemplating how to read an int using Scanner.nextInt(), and at the same time ignore the rest of the line or flush the input buffer to be ready for inputting ...
8
votes
2answers
293 views

Prime factorization of a natural number greater than 1

I am a math student who just started learning Java a week ago. I want to write a program in Java that return a prime factorization of any natural number greater than one. After spending some time ...
-1
votes
0answers
24 views

Java Program that reads a sentence from the user and prints the sentence with characters of each word backwards. (Using a stack) [closed]

I'm having a problem with figuring out why my code won't print the entire sentence. It will only output and reverse the order of the first word's characters in the sentence. How do I get this to ...