Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [java]

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 bytecode and run in a virtual machine (JVM) enabling a "write once, run anywhere" (WORA) methodology.

0
votes
0answers
4 views

Numbers adder via generics

This method add all numbers in list and return it as double ...
0
votes
0answers
37 views

String Mix Code Wars Kata

Problem Statement Given two strings s1 and s2, we want to visualize how different the two strings are. We will only take into account the lowercase letters (a to z). First let us count the ...
-5
votes
0answers
19 views

Search Name Option [on hold]

I was just wondering how I could add a search option to this program? I'm stuck. Ex: The program will ask the user to enter a name to search for. it will then display the index position of the name ...
-1
votes
0answers
27 views

Passing a list of base class objects to a method and using instanceof to filter [on hold]

I'm working on a Java reverse engineering project, where I am analyzing bytecode and trying to identify classes, methods and fields using the ASM framework. After identifying these I transform some ...
0
votes
3answers
56 views

Represent a Class which holds translation Strings [on hold]

I have a class which represents some translations of a keyword. ...
-4
votes
0answers
18 views

Need a java version of this mathematica code [on hold]

[https://www.wolframcloud.com/objects/paralesely/Published/a.nb][1] I am researcher and I find difficulties in studying my research because of my reference paper is written in Mathematica ,Wolfarm ...
-1
votes
0answers
26 views

Multiprocessing tool [on hold]

I am currently programming a multi processing tool with a GUI in JavaFx. I want to have your opinion about my code. This is code snippet from my main class: ...
0
votes
1answer
24 views

Program to check if heap order is correct or not

There is a Java program to check if a Heap (Min) is in the correct order. Heap Order means the parent is less than both left child and right child. ...
2
votes
2answers
29 views

Basic AES/CBC implementation in Java

A little bit about myself: I am 18 years old, a student living in Germany and currently working on an android app. I would like if someone has the time to review my code. I am especially interested ...
1
vote
1answer
35 views

Generic Binary Search Tree Implementation in Java

There is an implementation of Binary Search Tree. This is kind of based on Set Theory that duplicates are not allowed but an attempt to adding the same node twice will replace the older node. BSTNode ...
-2
votes
0answers
9 views

Native operation call failed.java.lang.UnsatisfiedLinkError: Test.Sample.Jni_sample.Jni_sample(DDDII)V [ERROR] [on hold]

I am using a java program to call .so file. Now I am getting an error (DDDII)V and i have no idea what might that be.. I am a complete noob.. Any help would be appreciated. Here is the lines that try ...
-2
votes
0answers
11 views

Method ordering for Requirements API [on hold]

Over the past couple of years I've quietly developed a library for enforcing API contracts. The project is hosted at https://bitbucket.org/cowwoc/requirements/ Users write ...
1
vote
2answers
27 views

Generic Min Heap Implementation in Java

There is a Min-Heap implementation in Java. BubbleUp() and BubbleDown() could have been coded using recursion but I prefer without recursion. Would there be a major difference if had used recursion? ...
2
votes
1answer
50 views

Find out whether a given text contains any of the prohibited words

We have been given a list of strings which are blacklisted. The goal is to identify if a given text contains any of these blacklisted strings. The restriction here is that the blacklisted string needs ...
1
vote
3answers
77 views

Simple Publisher Subscriber in Java

I am new to Java and had some difficulty creating this simple Publisher Subscriber class. It finally seems to be working and I wanted to check if I have been following best practices and see if there ...
-2
votes
1answer
59 views

Array insertion sort [on hold]

I'm attempting to sort an array at the initial insertion of a value. I tried to think "binary search", except with sorting, where I'm searching for the correct insertion point. I guess you can call it ...
0
votes
0answers
33 views

Simple Calculator Using Methods Parsing Problems [closed]

I am working on a calculator program for my class and im using methods and i have to take the entire equation in on one line and then separate it afterwards and that is where i am running in to a ...
2
votes
0answers
27 views

Mouse wheel scrolling for nested scrollable Swing components

By default, mouse wheel scrolling in Java Swing behaves differently than in web browsers. In Swing, when you have an inner scrollable component and an outer scrollable component, the mouse wheel ...
4
votes
2answers
256 views

Grade calculator for a project with four aspects

I have a program that will ask the user to input their grades for 4 different sections of a project, then tell them what their total mark is, what grade they got and how many marks away they were from ...
3
votes
1answer
75 views

Hackerrank “Almost Equal” solution

I've spent the best part of a day on this question. It is marked as Expert level. There are about fifteen submission test cases and my solution manages to satisfy the first four. However, from there ...
2
votes
2answers
86 views

Calculator to add time intervals

I have written a little program that calculates the time by given strings. A time string in the context of this program consists of a number and a following letter that can be s, m, h, or d. You can ...
2
votes
0answers
51 views

My first Java app: a calculator in Swing

I have created my first Java app. I am very familiar with C++ and thus without reading any books (just introduction, googling and IntelliJ auto-completion) I directly jumped into Java. So I made a ...
3
votes
1answer
54 views

Insurance Premium Quote Challenge

I was failed at coding challenge for my interview with the following reasons given by the interviewer: deep use of mutation and a not that well thought up internal API. I understand that my code and ...
-1
votes
0answers
13 views

View items from database using JSP [closed]

I have a table called Developers. ...
0
votes
0answers
14 views

File integrity while replacing 2 Strings in a file

Task I want to handle a XML file from a source I cannot influence. All XML files from this source have the "problem" that the < and ...
2
votes
1answer
54 views

CSV file download in Spring

I recently worked on a module, in which I implemented the functionality of downloading the CSV files. ...
1
vote
1answer
17 views

Adapter class to display songs in an Android ListView

I am learning Android with Udacity nanodegree (having no support) and this is my assignment of music app. It is just an interface and no music I have to add. So far so the app is running without any ...
2
votes
1answer
23 views

Printing all the combination of indexes for 2 sum exact outcome

Can somebody review the code and provide suggestions on where I can improve on the code like use of better data structure etc. Input: {1,7,2,8,3,6}, 9 Output: [0, 3] [1, 2] [4, 5] ...
0
votes
1answer
19 views

Java splitting too large text file enhance performance

I have a too large data.txt file containing data as follows: ...
1
vote
0answers
17 views

Sorting an array of numbers in Java with an algorithm

This is pretty much one of my first programs that I have created in Java and I just wanted to ask if anyone sees some obvious errors or mistakes I made. The purpose of this program is to sort numbers ...
-6
votes
0answers
26 views

WHAT is The Solution to the following Qusetion [closed]

Write java a program that asks the user to enter the count of numbers that he wants to calculate, then ask the user to enter the operation type (+ , - , * , / , % ): - Use switch statement to select ...
-4
votes
0answers
13 views

Java.NoSuchElementException error on second scanner [closed]

I’m using a iOS compiler app called JedonaCompiler and I am currently trying to code a small text based rpg. I’m adding in a “cmd prompt” of sorts so when I transfer the code to NetBeans I can ...
11
votes
2answers
4k views

Rock Paper Scissors game using OOP

I'm a complete beginner to Java and we have just started learning objects and classes in school. I'm trying to create a very simple text-based Rock Paper Scissors game. I do realise that my code is a ...
0
votes
0answers
37 views

LinkedHashSet Implementation

There's an implementation of LinkedHashSet in Java. Although this is limited with its functionality, it will do the basic job. I used interfaces so then I can use that interface for BST. Set ...
-4
votes
0answers
15 views

percfectly run but stringoutofboundexpection [closed]

import java.util.*; import java.util.Scanner; public class hackerFirst { ...
2
votes
2answers
69 views

Calculating the Factorial of a number

I am looking for feedback for the implementation for calculating factorial of a number. I have tried to do with a loop, recursion and in a mutlithreaded way. ...
2
votes
1answer
71 views

Speed up Magic square program

I have written a Java program to calculate magic squares with recursion and backtracking. A 3*3 Magic square is calculated in about 1 sec, but a 4*4 needs about 50 minutes on my laptop with Intel i5. ...
-4
votes
0answers
17 views

Static factory method vs adapter [closed]

I have a problem which approach is best. Please imagine system written in a hexagonal architecture where each service method accepts class or classes. Let say for example my method create User. 1. ...
3
votes
1answer
56 views

Card based game in Android

I am developing a card game in Android. This is my first time I am working in Android,. The game contains following features: It will be a 6 player game. There are two decks on the table, one with ...
2
votes
1answer
69 views

Java => Caesar Cypher

I already asked for help in optimizing a simple Caesar Cypher code in java here : Cesar code in Java I tried to implement all the advice from that subject and now I am asking again. Do you have any ...
0
votes
2answers
36 views

Printing the status of a database insertion as JSON

The controller is currently inserting a record into the database and returning a JSON response as shown below in the try-catch block. I can see the ...
-1
votes
0answers
27 views

Count the number of occurrences of each symbol in a string array

This calculates the number of occurrences of each symbol in a string array. I want to find some places in this multithreading code which could lead to a NullPointerException or other exceptions or ...
2
votes
1answer
76 views

Robot Block Command

Problem We have a robot that can pickup blocks from a stash, move them horizontally and lower them in place. There are 10 positions available to lower blocks number 0 to 9. Each position can ...
0
votes
1answer
48 views

A Java Quadrilateral Inheritance Hierarchy - revisited

This is an exercise from Deitel&Deitel's "Java. How to Program (Early Objects)", 10th edition. 9.8 (Quadrilateral Inheritance Hierarchy) Write an inheritance hierarchy for classes Quadrilateral, ...
0
votes
0answers
49 views

Detect the interval between time points

I want to detect the interval between time points. I want to ignore some anomalies if there are. The idea is choose some random samples and try to detect what is the interval between points in most ...
1
vote
1answer
43 views

Calculate the number of days passed from a given year

I have this code for calculating the number of days passed from a given year: ...
3
votes
1answer
31 views

Static class for database access Java JDBC

I'm writing a small program to store data in a database (a discord bot mainly). I know cleaner ways of using dependency injections and DAO exist, but I haven't written a DAO (or the user class) and ...
2
votes
1answer
55 views

Calculate arithmetic expression represented by a string, in Java

I saw that interview question online and gave it a try: Implement a function that gets a string which represents an arithmethic expression: contains only numbers or the the operators: '+', '-', '*', '/...
0
votes
0answers
53 views

Gift exchange name chooser

Before I post any code, I should probably explain the weird way we choose who buys stuff for who. My family is made up of three branches. No one buys for anyone else in the same branch. Names are ...