Questions tagged [java]

Java (not to be confused with JavaScript, JScript or JS) is a general-purpose, platform-independent, statically typed, object-oriented programming language designed to be used in conjunction with the Java Virtual Machine (JVM). "Java platform" is the name for a computing system that has installed tools for developing and running Java programs. Use this tag for questions referring to the Java programming language or Java platform tools.

Filter by
Sorted by
Tagged with
-1
votes
0answers
23 views

How can I solve this nullPointerExecption i am getting from line 71? (Java)

I am creating a calculator that uses 2 stacks to calculate users input utilizing a stringtokeinzer. When i do basic math, the code works but when i include a parenthesis to do multiple calculations, i ...
1
vote
0answers
11 views

Method not Supported by Remote Object

I have two applications. A server app that registers the RMI object and a client app that uses the remote object. In the client I create a message class that implements serializable and sends it to ...
0
votes
0answers
18 views

Struggling on getting correct method return value

My goal on this method which is part of a bigger assignment is to get the total number of bags of sugar for 2 recipes. I believe all of my conversions are correct but when checking it against a test ...
0
votes
0answers
6 views

How to fix image display incorrectly in FlexboxLayoutManager?

I have a RecyclerView in which the FlexboxLayoutManager is located. My problem is displaying images in FlexboxLayoutManager: image As you can see in the image, there are gaps and I would like ...
0
votes
2answers
23 views

How @Controller, @RequestMapping, @RequestParam internally work in Spring Boot?

If my understanding is correct, you can add/remove params for saveEmployee() freely. For example, when you add "loc" as follows, saveEmployee() receives the "non-null object" when the event happens. ...
0
votes
0answers
12 views

Jackson serialization and deserialization of a 3rd party class without writing a custom serializer and or deserializer

This question will probably sound like a duplicate but I can't piece together a complete solution to my problem. I've tried using custom ser/deser classes but that gets tedious really fast (and ...
0
votes
0answers
7 views

Using Fragments as NAVIGATION DRAWER

i have an activity with two fragments in it, now i want to use one of the fragment as navigation drawer in the application (slide in/out at button pressed) activity_main.xml <?xml version="1.0" ...
0
votes
1answer
12 views

Problem in viewing in custom-listview in android

I wanted to display some images from a folder form mobile SD card. I written an adapter to display image and file name. Unfortunately the app is not showing the list view. What's wrong with the code ...
0
votes
2answers
28 views

Why use Java/Kotlin instead Python on Android?

I'm novice. That's why I can't understand the essential difference between using Java/Kotlin or using Python with its numerous modules for Android application development. Is there a good reason that ...
0
votes
1answer
29 views

InputMismatchException error in java code. Please give some advice

For some reason I keep getting the inputmistmatch exception on line 44 (int fileAge = inputFile.nextInt();) I have tried isolating that part of the code and using it with a manually created file and ...
1
vote
1answer
27 views

Will Strings logged in loop pollute memory?

consider code: while(true) { System.out.println("Current time: " + System.nanoTime()); } Will this code pollute memory with strings? My app should print such log in loop for 5-10 hours into ...
0
votes
2answers
20 views

How can I declare an instance variable(of type inner class) in the outer class?

I want to declare an instance in the outer class, before I have defined the inner class, but in code blew its cause issue: class LinkedList { Node head; //line3 class Node //line5 { ...
1
vote
1answer
26 views

How do I copy objects from a ArrayList and order them by int size in a HashMap?

So I need to make a leaderboard, the place on it depends on the quantity of points a Client has. This is the Client, public Client(String username, String password, String phoneNumber, String ...
0
votes
1answer
32 views

why is there a difference between return ++arg and return arg++

Let's consider following code: class Year{ int nextyear (int curr_year){ return curr_year++; } int nextyear2 (int curryear){ return ++curryear; } } class Main { public ...
0
votes
2answers
19 views

How to leave space, go to next line , underline or make characters bold in knife.fromHtml() ? \n, \t, \r nothing is working

String x = this is my \n sentence; knife.fromHtml(x); When I use this sentence is not displayed in a new line
0
votes
0answers
6 views

How to add headers and footers in google doc in java

I want to add header and footer in google doc using java.How can i find header and footer id.
-1
votes
0answers
13 views

Java: Construct next lexicographic string for given string

I am working on a search algorithm and I need to subdivide the search space. A problem that I am stuck with right now is that I need to compute the next lexicographic string for a given input string, ...
1
vote
0answers
8 views

Jaxb Marshals the same XML Message

I am using Jaxb for marshalling and unmarshalling objects. This is the code of my custom class for the purpose. import test.org.swt.SwitchMsg; import test.org.swt.TrxMsg; import org.springframework....
0
votes
1answer
19 views

Java Why is my While loop being ignored for every input I type in?

I'm trying to figure out why my while loop in my main method is being ignored even though I haven't entered "quit". The program is supposed to take in a user's input (converted to int), have the ...
-2
votes
0answers
22 views

I get compilation error when creating object for another class at class level

How can i avoid this compilation eroor? I tried creating objects inside static block also import java.util.Scanner; class UserInterface { private Scanner sc=new Scanner(System.in); ...
0
votes
0answers
5 views

Bounds and position in entity component system

I am working on a game engine mostly using ECS (not pure ECS) and I've run into a problem. Some entities will need a Bounds component (e.g. a component that has a Rectangle that represents position, ...
0
votes
1answer
14 views

Trying to Change the inventory declaration in the Inventory class to be an object of ArrayList and then fixing everything so that it runs correctly

This is a program that allows users to add data to a system. This is specifically the invetory class of the program where our task is to convert the object inventory into an object of an array list... ...
-1
votes
1answer
28 views

How to make textArea object accessible

I have been coding for about 3 months now, (I've never had any programming experience) and I ran into a bit of an issue. I'm working on an idle clicking game, but I can't seem to access textArea. I ...
1
vote
0answers
16 views

Running a .java file and instantiating the class contained in it give me different results

I have a Java program that is using threads to transfer data through sockets. The issue I am having is in my server manager when I create a thread pool. If for instance I create a thread-pool of 3, ...
0
votes
0answers
13 views

How to display table information in JavaFX

The following code is supposed to display the Parts from the Inventory AllParts Observable List. I'm unsure if this is the inventory class not returning the correct object, or if there is something ...
-1
votes
3answers
26 views

How do you fix an incompatible types error? [duplicate]

The program I wrote is giving me an error and i don't know how to fix it. I've tried a few different things and they didn't work. public static boolean isVowel(char c) {     c = Character....
0
votes
1answer
14 views

ViewPager with adapter “ ” requires a view id In AsyncTask

I have an AsyncTask in which I create a ViewPager and when I assign an adapter to it, this error appears java.lang.IllegalStateException: ViewPager with adapter [email protected]
0
votes
1answer
38 views

Unable to resolve dependencies with Android Studio and Firebase

Following are the error I get, please help me! ERROR: Unable to resolve dependency for ':[email protected]/compileClasspath': Could not resolve com.google.firebase:firebase-core:17.2.0. ERROR: ...
0
votes
2answers
18 views

Read Json return with Gson when the name of “parameter” change

I'm working on an app-client to connect with Open Library API (https://openlibrary.org/developers/api) to get some information by Json return reading by Gson from google, but I have a problem with one ...
1
vote
1answer
15 views

How to use Jackson DataType: JSR310 Deser standalone?

I'm in a scenario where I'm converting from type A to type B. Type A has a date field which is of type YearMonth, and type B's date field is a String. I don't want to reinvent the wheel, so it'd be ...
-1
votes
0answers
13 views

Trying to figure out how to make this n queens method stop once it gets all all of the solutions, what are some ways to approach this problem?

I am working on the good ol' N-queens problem using a stack instead of recursive calls in order to find the total number of solutions for N Queens. I believe that the program I have works, except I am ...
0
votes
0answers
28 views

How do I convert int into object datatype and use it with .equals

I have an overriding equals method that accepts an object datatype and compare the objects against each other like this. @Override public boolean equals(Object obj) { try { ...
-1
votes
0answers
14 views

How to add to an ArrayList from another class in java? [duplicate]

I am trying to add objects to an ArrayList from another class in java. I have an ArrayList set up to hold names in a class and I want to add to that ArrayList from a main class. I also want to assign ...
0
votes
2answers
24 views

Error with JunitTest: Would love advice and suggestion on my code

I have some problem when trying to do the 2nd test in my Junit as my questions stated: In the JUnit test, Test that the fourth element in the subjectCode is BIT111, that the fourth element in the ...
1
vote
2answers
37 views

Error when trying to convert string to integer using Integer.parseInt()

***Updating my post to show all of my code, hopefully this provides more context. When I run the program, it skips through my first "if" statement and throws an error.*** I am getting the error ...
0
votes
0answers
10 views

Get values from a sheet referncing another sheet within the workbook

I have to read all the values from a sheet using apache poi. However, the sheet references values from another sheet. For eg. I have to read cells of sheet1 which reference values from sheet2. Like ...
-8
votes
0answers
17 views

Assignment about products in java [on hold]

Choose a product that lends itself to an inventory (for example, products in your home, school, or workplace: office supplies; music CDs; DVD movies; or software). • Create a Product class called ...
-1
votes
0answers
19 views

What happens to the old string when we assigned it to other String [duplicate]

I have below code string s assigne do abc and then assigned it to dcf what happens to abc? String s="abc"; s="dcf"; System.out.println(s);
0
votes
1answer
18 views

Is it possible to design one Google Datastore index for these two queries?

I would like to know if it is possible to design Google Datastore indexes and queries in a way that I can reduce the number of composite indexes needed for my project. I have been trying to use one ...
0
votes
0answers
9 views

How do I add constraints to the Multiple Knapsack problem using Google's OR-Tools

This is cross posted on the or-tools Google Group. I will start off by saying, I am not an expert in this area by any means and I am looking to get some substantial help here... with the hope of ...
0
votes
1answer
10 views

Is there a way I can loop the checking of the state of Frame.state, w/out looping the code in the check?

I want to be able to continuously check the value of Frame.state, without continuously looping the code within the checks. I want to be able to either check the value or check when a button has been ...
-2
votes
0answers
24 views

Why would NullPointerException occur? [duplicate]

I have a NullPointerException occurring on a line which I wouldn't think such an exception could occur. Java level is Java 8 (from 2019). This is not the exact code but summarizes the relevant code: ...
0
votes
0answers
7 views

Transfer clothes on a real mannequin in OpenCV

How can i transform clothes on the mannequin with java in OpenCV. Which algorithms should be used.The shape of the clothes don't match with the mannequin.I appreciate your help.
0
votes
0answers
12 views

Does Gradle print text like CMake?

I have a question about Gradle tasks. I'm following the tutorial about tasks, and I have this code: task('hello') << { println "tutorialspoint" } Is the println method a way to print text like ...
0
votes
2answers
27 views

How to make file input stream ignore escape characters

Essentially i have this method that is supposed to read raw characters from a file and return them but something that i had'nt taken into account was the fact that it would add escape sequences to the ...
0
votes
0answers
11 views

Convert Dataframe Dataset<Row> to JSON Format of String Data Type for particular Columns and convert the JSON String back to Dataframe

I am using Spark Java to read messages in the format as Dataset. I need to call a Rest API method(passing only few selected columns- PID, ACCOUNTNUM). The method expects the list of records coming in ...
0
votes
0answers
15 views

How to authenticate a user with OAuth2 in spring?

This is my code called UserController package co.edu.unal.software_engineering.labs.controller; import co.edu.unal.software_engineering.labs.model.Role; import co.edu.unal.software_engineering.labs....
0
votes
0answers
18 views

Intersecting prevent moving in some situration

I got a small "test platformer game" and I have a collision problem... Normally, top/bottom/left/right collision work perfectly until I realise 2 problems... Problem 1. I built a 3 block wall, I ...
0
votes
0answers
10 views

How can I make a LED work with Java and IOIO?

I need to develop an app that launch a video and light on a LED at the same time. App containts three screens : home screen (or menu) on which there will be two images / one screen for the "gare" ...
0
votes
1answer
12 views

Extra null for Android Notification with PendingIntent

I am trying to send a int Extra to an Activity when a notification is tapped. When I tap the notification the activity launches, but the extra is always null. I have checked a lot of similar ...