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
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

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
11 views

Global Map Holder

Global Map Holder - I want to make it more SOLID and DRY There are 2 aims of the packages: First is to provide easy access to 3 csv files: * currencies fix rates (nbp) * programming languages list (...
1
vote
2answers
43 views

Subset Sums in Java

Given an array of integers, print sums of all subsets in it. Output should be printed in increasing order of sums. Input : arr[] = {2, 3} Output: 0 2 3 5 Input : ...
-3
votes
0answers
7 views

in play framework, inserting multiple array of data with diffrent properties in database [on hold]

i want to insert marks of student, meaning that each student have his own marks, and have his id, now i want to insert list of students, each with unique identifications, means in list of student, ...
1
vote
2answers
46 views

Sort all even numbers in ascending order and then sort all odd numbers in Descending order Java

Given an array of integers (both odd and even), the task is to sort them in such a way that the first part of the array contains odd numbers sorted in descending order, rest portion contains even ...
5
votes
2answers
261 views

Vowel Counter 2000

Today I present to you a program that: Identifies vowels and their total number Prints each vowel's numeric value Adds the numeric value of each vowel found Prints which letters are NOT vowels If ...
3
votes
1answer
57 views

Developing a method of programming a multi-level menu

I am attempting to create my own speech to text assistant. This involves the user speaking and the assistant responding to the user's input. I do this by looking for keywords that indicate the user ...
0
votes
0answers
11 views

Binding a foreground service in Android for OREO

I have created a service that will act both as bind and foreground. Am I doing it in the right way? Kindly review it. ...
3
votes
1answer
68 views

Array Partitioning

I have a method in Java that I'm using to partition byte[] arrays into a number of fixed-size sub-arrays. It's not necessary for the last array to be that size, but all preceding ones must be, and the ...
0
votes
0answers
51 views

Quine McCluskey Algorithm

This is a program that uses the Quine McCluskey algorithm to simplify user inputted minterms. This is the main ...
3
votes
1answer
53 views

Managing database connections for unit tests

I have a series of unit test classes that use various connections to a database. Every test class uses two methods with the JUnit annotations BeforeClass and AfterClass to start and stop the database ...
0
votes
0answers
18 views

Inserting and updating room database entries in two Android activities

I have Activity1, where I display Room database entries in form of LiveData in a RecyclerView, and Activity2, where I have the necessary fields to add and update new entries. I wonder what is the ...
0
votes
1answer
32 views

Change variable location to a class outside of the GUI button [on hold]

I currently collect all of the variables from my GUI in the Enter button action. Is there a way for me to get all of this out of my enter button and into another class to clean up the look of it? <...
1
vote
2answers
53 views

Unit of measure class for mass in java

I was looking at this answer on SO to handle units in java. The concept was interesting to me, except I didn't like that it had to be per object that had mass, instead of encapsulating a ...
1
vote
0answers
29 views

Utility Class for location functionality on Android using Google Play Services FusedLocationProviderClient API

I'm new to Android development and this is my first request for a code review. Constructive criticism is very welcome! I've written a class to wrap interaction with Google's ...
-3
votes
0answers
44 views

Parallel computing [closed]

Measuring the effect of Parallelization Using one of the suggested methods in class ( p-threads, OpenMP, C-Sharp or Java Threads) implement an application that adds two integer vectors (A,B) and store ...
-1
votes
0answers
17 views

How to insertItemAfter in linkedlist java [closed]

so I wanted to insert an item after and this is my code for insertitembefore: ...
1
vote
2answers
75 views

Minecraft resource calculator

I'm writing a basic program that calculates the total base resources needed to craft items in Minecraft. It's intended to be modular for support for modded versions of Minecraft (new items or ...
0
votes
0answers
22 views

Android mini game background handler

In the same project as in my previous questions I have released a new beta ("0.1.24b") of the game we call "Moon Buggy". It is now possible to get the background to change when completing a section, ...
3
votes
0answers
38 views

Android audio recording using AudioRecord and ByteBuffer

I'm developing an audio recorder app for android using AudioRecord class to have a low level access to audio samples. ...
3
votes
2answers
57 views

Counting pairs that have a given difference in Java

You will be given an integer k and a list of integers. Count the number of distinct valid pair of integers (a,b) in the list for which a+k=b. For example, the array [1,1,1,2] has two different ...
0
votes
1answer
64 views

Casting the left and right numbers as integers or doubles

How can I remove the code duplication in this code? It is trying to cast the left and right numbers as integers or doubles and then using it. ...
-5
votes
0answers
33 views

how to create stopwatch for microcontroller atmega328p [closed]

How can I create stopwatch a assembly code for Atmega328p micro controller is there any one providing this code?
-5
votes
0answers
61 views

Readability Vs Efficiency [closed]

Readability Vs Efficiency V1 and V2 are equivalent. V1 is more readable, but V2 saves the call to function_call_2. What should be the ideal choice? V1 ...
0
votes
1answer
57 views

Pythagorean Theorem in Java

I'm new to Java and am following a series of lectures on Stanford's YouTube. I know that the code works, but I'd like to know if it can be improved upon. ...
4
votes
2answers
84 views

Minimum difference between numbers in a file

I'm learning Java and I created a simple solution for the following problem: Given a file [filename].txt such that each line has the format ...
2
votes
1answer
63 views

Breakout-style game

I'm trying to learn how to program with Java which is more or less my first programming language (had some basic Pascal and C,C++ in school and college) but still a Beginner, with a capital 'B'. ...
4
votes
3answers
104 views

Java RPG battle simulator

I'm coding a turn-based RPG battle simulator (text based) in Java. I'm doing this as an exercise/project to learn OOP design. I've coded something similar in C, but just porting that code over to ...
0
votes
0answers
25 views

Confusion about Java object types [closed]

I'm trying to find the smallest integer greater than 0 that is not in a given list. For some reason, this code outputs 1, because java thinks 1 and "smallest" are different values. Can somebody please ...
-3
votes
0answers
14 views

How establish auto previous connection after server down in socket? [closed]

I am doing one socket programming in java. If server socket is down for a while then start again after that the server can get auto connection with the client which connect with previously.If possible ...
0
votes
0answers
33 views

Is this a good way of retrying operations using recursion?

This is in context of a springboot application. I considered using Spring @Retryable too but found that it didn't work with function with return types. Is this approach considered good? ...
0
votes
0answers
14 views

Viewadapter with viewholder and async task

I'm writing a small mobile app, foremost for myself and a few other people, but it won't probably get a huge userbase(but one never knows). I do want a clean architecture though, so here is my code ...
1
vote
0answers
31 views

Consuming APi using Rx in an MVP project

I would like to have some input here if possible, this code should make a request to an API and the call should return the desired object. The client to make the requests was made with Retrofit and ...
0
votes
0answers
11 views

Multi Type view item to firebase store

I am adding a multi type question to firestore: ...
2
votes
2answers
88 views

Google Foobar level 3

Over the past few weeks, I've been doing the Google Foobar challenges and I've been progressing quite well. I'm currently 1/3 of the way through the third level. However, there were plenty of times ...
4
votes
2answers
53 views

Semaphore skipping additional threads

In this example I've a refresh method that might be called by multiple threads. Requirements are: refresh() method must be processed by only one thread at a time (...
1
vote
0answers
41 views

Correct Callback for each item

I have added a correct question callback for different types of questions like: radio, checkbox and descriptive.. QuestionListActivity.class (it shows the list of questions to attempt) ...
3
votes
3answers
586 views

Find the longest ascending subarray from a given array

I have following task, form a given array, I want the longest ascending array. I will give you an example int[] a = {19,12,13,1,2,3,4,5,14,23,24,25,26,31,32}; ...
0
votes
3answers
67 views

“Human” interfaces with two implementation classes

The Helloworld class executes all of the methods. Human is the interface, and Nate & <...
0
votes
2answers
61 views

Implementing many-to-many

I'm looking for advice on implementing many-to-many. I'm modeling a site such as stack exchange: each Member has many Groups, each Group has many Members. I've introduce a Membership class. This class ...
0
votes
1answer
55 views

Password and confirm password validation in Android Studio

I just wrote this password and password confirmation validation code function that checks to see if a password is empty or not, and is it match (password = confirmPassword). I'm not sure this is the ...
5
votes
3answers
100 views

Java version of card game “higher or lower”

First of all, I have my basic main method which does pretty much nothing: ...
3
votes
1answer
44 views

Java Concurrent Recursive API Access

I don't get to write multithreaded applications very often, so be gentle with my threads :-) I have an API input which contains a "score" and then a bunch of child nodes which also have scores, and ...
3
votes
1answer
95 views

Java Messenger data transmission

This is a very simple concern, could somebody take a look at a few lines of my code? I'm writing a simple Java multi-user messenger, it is structured in a desktop client with a Swing GUI, a java ...
5
votes
5answers
188 views

Sort an array of 0s, 1s and 2s in Java

Write a program to sort an array of 0's,1's and 2's in ascending order. Input: The first line contains an integer 'T' denoting the total number of test cases. In each test cases, First ...
5
votes
2answers
75 views

Pig Latin Anslatortray

I've created a program that translates any word into the form of igpay atinlay or pig Latin! I got the project idea from here and you can read the rules here. My program outputs the same translation ...
1
vote
1answer
64 views

Java Regex for Chess notations

I have this regex: (\d?)[A-Za-z](?=(\d?)(.*))(?=(.* ){5}) It would be used by me for Chess FEN strings. I wonder if regex ...
3
votes
1answer
70 views

Regular Expression for text that validates IPV4 or Hostname followed by a port number eg: 127.0.0.1:8080 or localhost:8080

An attempt with regular expression to do a foolproof validation of an IV4 or Hostname:port Number. Example texts that can be validated for any of the following: ...
2
votes
6answers
416 views

Alone in a Couple implementation in Java

In a party everyone is in couple except one. People who are in couple have same numbers. Find out the person who is not in couple. Input: The first line contains an integer \$T\$ denoting ...
0
votes
2answers
158 views

Fetching data from your database in a constructor

I have this item (an item is an object linked to a xml view), to build it I need 2 things, get labels from codes, and get text from the strings.xml android file. please ignore the long to int and int ...
2
votes
0answers
28 views

KeyEvent listener: mapping physical keyboard to onscreen keyboard [closed]

I have an assignment to create a GUI with a keyboard and text area. Conceptually, the user would type on the physical keyboard and the respective key would change background on screen to reflect that ...