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.
0
votes
0answers
6 views
implementation of remove method in simple linked list
I want to implement a remove method in my simple linked list : it removes a node in my list ... The implementation according to my teacher is like this :
...
-1
votes
0answers
6 views
Improving noob-written Java code
I've just begun programming Java and I'm working on the following code that deals with socket-based communications. Basically it connects to a client on port 8888:
...
3
votes
1answer
27 views
Counting occurrences of a word in a file
This gives me the output of how many times the word is in the file. (I will eventually want to enhance the program to output on what line of the file the word is.)
...
2
votes
2answers
20 views
SortedList implementation in Java
I've implemented a SortedList which takes in streams of floats and returns a median at any point.
...
0
votes
0answers
20 views
Finding Kth Permutation Sequence
I have written a program to display the kth permutation sequence of a string made up of letters 'O' and 'Z' . I tried optimizing it but my code have not passed test cases due to timeout issues.Looking ...
-4
votes
0answers
10 views
Draw Octagonal Grid [on hold]
I have developed a program to draw Octagonal Grid. How do i write pseudo code for the same
OCTAGON.java
...
4
votes
3answers
187 views
Using Enum to Handle String literals
I have a java component that was using a lot of string literals that I need to make comparisons on and return booleans based on these comparisons.
In order to make the code more robust I externalized ...
-4
votes
0answers
17 views
1
vote
1answer
27 views
Reading a CSV file containing a dataset of 8×8 images
I am trying to implement a machine learning algorithm (k-nn for example). But before I attempt to do that I was hoping for some feedback on my current Main class, which essentially builds 8×8-pixel ...
0
votes
1answer
21 views
1
vote
0answers
22 views
Student/Class App Java/MySQL
I posted a question about this code yesterday and have made several updates. I'd just like to know if there are any other major errors or spots for improvement. I have three MySQL tables:
...
-1
votes
0answers
26 views
Validating a database connection
I need to validate database connections in a separate function.
Why is SonarQube plugin for Jenkins complaining about the open statement if I close it in the finally block?
...
0
votes
0answers
18 views
Checking if a 3D point is outside of a trapezoid
I have recently written if a 3D point is within a specified trapezoid. It does it by checking 3 different planes of the trapezoid. I place the relevant 2 coordinates from the 3D point into the current ...
2
votes
2answers
41 views
is my add method in binary search tree correct [on hold]
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 :
...
1
vote
3answers
77 views
Logic for shuffling sliding puzzle
I'm working on a sliding puzzle, one little project as a hobby, 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 ...
2
votes
1answer
24 views
Fractional Knapsack
This is my solution to an assignment on the fractional Knapsack problem. I take as problem input the following pieces of information:
The number of item types
The total weight limit
For each item ...
8
votes
2answers
362 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
...
2
votes
2answers
34 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
18 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
30 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. ...
9
votes
3answers
616 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
0answers
22 views
-3
votes
1answer
48 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
79 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
20 views
Java 8: effective usage of Optional and Function [on hold]
I've wrote the following constructor:
...
0
votes
0answers
15 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
...
3
votes
2answers
37 views
Parallel integer Quicksort in Java
Now I have that parallel Quicksort for (primitive) integer arrays.
ParallelIntQuicksort.java:
...
3
votes
1answer
178 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
53 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
55 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
41 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
28 views
0
votes
1answer
37 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
20 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
75 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
29 views
Retrieving access token from SharedPreference
Here is code that retrieves an access token from SharedPreference.
...
4
votes
1answer
319 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 [closed]
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:
...
2
votes
1answer
55 views
0
votes
0answers
8 views
5
votes
3answers
333 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
50 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 ...