Home >

# java

• ## Tile collision detectionApril 24

Right. So I was making this simple game. The player is two tiles wide, and four tiles high. My current code is really buggy (it was better before my rewrite) Here it is: float newx = position.x + velocity.x; float newy = position.y + velocity.y; int

• ## What is the concept of variable-free programming?April 20

What does it mean by concept of variable-free programming? I have to write a program which adhere to concept of variable free programming for my class assignment. But I have no idea about the concept of variable-free programming. here is the instruct

• ## Stack having push, pop and return min in o(1)April 7

Here is my approach, class MinStack { Stack<Node> s1 = new Stack<>(); public void push(int x) { if(s1.isEmpty()) { s1.push(new Node(x,x)); } else { s1.push(new Node(x,Math.min(s1.peek().min, x))); } } public void pop() { s1.pop(); } public int

• ## Java loops in Map Reduce MapperApril 7

New to Java and can't get this loops and arraylist working correctly. Working on identifying co-occurences of Actors in a shakespeare play. The map and reduce should produce (Paul, Mary) 25. Indicating they were together 25 times. Below is the map fu

• ## Integer tree sort in JavaApril 7

I have this algorithm for sorting integer arrays. Basically, it's a balanced tree sort which creates a tree node for each distinct integer, and in each tree node it maintains a counter counting how many times the integer key appeared so for in the ar

• ## How to create a boolean method that allows users to type in yes/y or no/n instead of true and false in java [on hold]April 7

public boolean getYesOrNoAnswer(String yesNoPrompt) is all I got. Also it should be a method that can be called latter on in the code

• ## Adaptive counting sort for integer arrays in Java - follow-upApril 6

I have refactored this. Once again, the running time can be anything between \$\Omega(n)\$ and \$\mathcal{O}(n^2)\$, yet it adapts to "smoothness" of the input array. AdaptiveCountingSort.java: package net.coderodde.util.sorting; /** * This clas

• ## Convert objective-c method EVP_DecryptInit_ex to java for encryptionApril 3

How to convert blow objective-c method to java? I am trying to Convert objective-c method to java for encryptions, the encryption method in objective-c is EVP_CIPHER_CTX, and I wonder what related java method? +(int)seafileDecrypt:(char ​*)data_out o

• ## The Exception Stops the program in the arrayApril 2

This is the Exception class public class IllegalValuesException extends Exception { public IllegalValuesException(String message) { super(message); } public IllegalValuesException() { super("Illegal Values"); } } This is Tringle class public cla

• ## How to check how many constants are in enumeration?April 1

I have a enum: public enum Platform { Xbox360, XboxOne, Playstation3, Playstation4, PC } I want to iterate and print all constants from it. How can I get size ? Or for this purpose I shouldn't use enumeration but let say arrays? --------------Solutio

• ## Can't access native library of tesseractApril 1

Although I have placed the dll in the resource path It keeps telling this error java.lang.UnsatisfiedLinkError: Unable to load library 'libtesseract304': Native library (win32-x86-64/libtesseract304.dll) not found in resource path ([file:/C:/Users/Us

• ## How to run .jar fileMarch 27

I am currently running Windows 10 and am trying to open several installer .jar files for a game. In order to open the, I downloaded Java as that seems to be the most straight-forward way to do so. However, I am unable to actually "open" Java, I

• ## Why should parentheses be used in an if statement?March 21

My document says: This is incorrect: if b == 1 This is correct: if (b ==1) It says that the parentheses forces the expression inside to be evaluated first. Why does this matter? --------------Solutions------------- It is a syntactic requirement. The

• ## Java REST WS with DBMarch 12

I want to get the feedback this code about the best practice I should follow and if I am using the connection pooling properly. I have classes as follows: DAOConnectionFactory- to fetch pooled connections from the Datasource WatcherService- the REST

• ## Encapsulation for Reference Variables?March 9

It may be a common qustion but i couldn't find nice explanation for it. I am trying to understand the encapsulation of reference variables in Java. In the below code: class Special { private StringBuilder s = new StringBuilder("bob"); StringBuil

• ## Unable to access Inner Interface of classMarch 6

I have an adapter class for recyclerview: public abstract class RecyclerViewArrayAdapter<T, VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<VH> { ... } I am creating an object like this : new RecyclerViewArrayAdapter<String

• ## Is there a way to input a unicode value and output its respective char?March 5

I have here some code trying to output seat numbers. The output is formatted as such for numRows = 2 and numCols = 3: 1A 1B 1C 2A 2B 2C My problem below is with my char.forDigit method. What I am trying to do is input Unicode values (65 being A, 66 b

• ## How can I set a Steam achievement in Steam via LibGDX or native Java?February 14

Is it possible to set or 'unlock' a Steam achievement via LibGDX or with a native Java solution? If so, how it this possible. Furthermore, what would be a good implementation for 'saving' achieved achievements when you were offline. For example, when

• ## Recursively defined instance variables?February 9

I'm in the midst of learning and understanding the structure of Java (coming from Python) and am having some difficulty building an Infix Calculator. I a Calculator, BinaryExpression, ExpressionManager, Number, Operator, and Token classes and an Expr