Click here to Skip to main content
15,879,184 members
Everything / Programming Languages / Java

Java

Java

Great Reads

by ridoy
A brief explanation of application development for Android Wear, helpful for every beginner and intermediate android developer.
by raddevus
Steps for building a device you can add to your existing garage door, which implements an atmega328, bluetooth (hc-05) and relay module which will allow you to open your garage door from any paired Android device.
by Arthur V. Ratz
In this article, we will discuss about the advanced Android application development based on the example of creating a responsive Airport schedule simulator application.
by Afzaal Ahmad Zeeshan
This post attempts to describe the general difference between overloading and overriding in Object-oriented programming languages.

Latest Articles

by Yochai Timmer
A way to avoid JNI's reflection oriented programming. Wrapping Java with C++
by JudyL_MD
Code sample for passing encrypted compressed data between Windows and Android
by Han Bo Sun
This is a more in-depth tutorial on integrating Lucene search and index engine in Java applications.
by Łukasz Bownik
Smallscript is a little scripting language inspired by Smalltalk syntax.

All Articles

Sort by Updated

Java 

U 8 Apr 2024 by Patrice T
Advice: Learn to indent properly your code, it show its structure and it helps reading and understanding. It also helps spotting structures mistakes. Scanner sc = new Scanner(System.in); System.out.println("Ingrese un número"); numero =...
U 8 Apr 2024 by Nayeli Guitarra
Perform this exercise in Java language: Create a program in which you enter integers and calculate: to. the product of all even numbers less than 25 b. The sum of all odd numbers greater than 16 c. The average of all numbers multiples of 4 What...
N 8 Apr 2024 by OriginalGriff
Move the read of the number inside the for loop ... Two other things: 1) Read the question carefully: the first part requires even number, the second odd, but the third needs odd and even. There is no "third state"! 2) Pick an indentation...
U 8 Apr 2024 by Pritong water
You are given a text file named sentences.txt, which contains a list of sentences separated by newline characters. Each sentence is composed of words separated by spaces. Your task is to read the sentences, reverse each sentence, and then output...
N 8 Apr 2024 by Pete O'Hanlon
You have all the information you need in the assignment. We don't write the answer to assignments, as this won't benefit you. Take the question, and break it down. Work out what you, as a human, would do in small logical steps. If you get code...
U 8 Apr 2024 by VortexV7
The chats/messages are not appearing on my app's chat windows but when I have checked my firebase database it is showing there properly. Here is the code please look into it. ChatWindow.java package com.vortexv.vconnect; import...
U 6 Apr 2024 by Pete O'Hanlon
Add an empty default constructor to the class.public Users() {} The error told you exactly what the problem was.
N 6 Apr 2024 by VortexV7
I am using firebase as my database for my app which is an chatting app. And my app is crashing whenever I try to login or sign up to my app main activity the app crashes automatically. MainActivity.java package com.vortexv.vconnect; import...
N 4 Apr 2024 by Pete O'Hanlon
To add to the advice given here - you can actually test to see if your scanner has any more input to work with by using the hasNext(); method to determine whether the scanner has anything else to do or not.
N 4 Apr 2024 by OriginalGriff
Start by looking at the error message closely - this will help: How to Write Code to Solve a Problem, A Beginner's Guide Part 2: Syntax Errors[^]. It's primarily about compilation errors while your problem is a runtime error, but the information...
N 4 Apr 2024 by Graeme_Grant
This should help you identify the issue: How to Fix the No Such Element Exception in Java | Rollbar[^].
U 4 Apr 2024 by Cindy Ann
import java.util.Scanner; public class MyCalculator { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); // userInput // i searched online how to restart a program with y/n ...
1 Apr 2024 by Pete O'Hanlon
Let’s suppose that we help you with something that looks like homework. Suppose we came up with the solution for you. How do you think that would help you. Any code that we wrote would be our code, not yours, so you would be in a position where...
1 Apr 2024 by OriginalGriff
While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for...
31 Mar 2024 by Patrice T
First error, but not the last: currOR ^= nums[left++]; '^' is the xor operator, you want to use '|' the or operator. Your code do not behave the way you expect, or you don't understand why ! There is an almost universal solution: Run your code...
30 Mar 2024 by OriginalGriff
Compiling does not mean your code is right! :laugh: Think of the development process as writing an email: compiling successfully means that you wrote the email in the right language - English, rather than German for example - not that the email...
27 Mar 2024 by Yochai Timmer
A way to avoid JNI's reflection oriented programming. Wrapping Java with C++
21 Mar 2024 by OriginalGriff
This is one of the most common problems we get asked, and it's also the one we are least equipped to answer, but you are most equipped to answer yourself. Let me just explain what the error means: You have tried to use a variable, property, or a...
21 Mar 2024 by UT7
I've resolved this issue, start.spring.io created a package for the main class where the SpringApplication.run method is and I created my other packages on the same level as the package where the main class was instead of creating them directly...
21 Mar 2024 by Jordan Schwartz 2024
Using the source code given, update the simple list to your top five chosen destinations. Include the destination title, a short description, and a small image for each. This will help ensure that you have fulfilled the acceptance criteria of the...
19 Mar 2024 by Pete O'Hanlon
The beauty of annotation processing is that it doesn't require you to explicitly pick a type in the @SupportedAnnotationTypes. Change that line to @SupportedAnnotationTypes("*") and this should pick up any annotations that you have in the project.
19 Mar 2024 by Pete O'Hanlon
Without knowing where you were sourcing your data, this is an almost impossible question to answer. There are a few things that do occur from looking at this. You are adding a random UUID but that could easily be auto-generated by the database....
19 Mar 2024 by OriginalGriff
Nobody can guarantee you "a fraction of a second" to add a million rows to a DB, PostgreSQL or not - it will depend on far too many factors: the computer(s) that the DB engine is running on, the activity level on the DB, the connection between...
18 Mar 2024 by Office Systems
I'm having an array list which has more than 1 million of records in it, I want to dump it as the way it is in PostgreSQL database using something built in methods like Copy-manger or any method which will be more faster to import this large...
18 Mar 2024 by Tyler Bakeman
In Eclipse Marketplace (which you can access through the Help button in Eclipse), it shows your plugins (some of them, not all of them), such as M2E. When I switched M2E, to an alternate in Eclipse, it gave me the option to “change”/“disable”...
18 Mar 2024 by Tyler Bakeman
I hope this message helps you to continue. Before I tackle the moveFishes method, as well as some of the other methods (changeDirection, turnFish, etc), I think we should take a look at how we store all of the fish themselves: Your fish are...
18 Mar 2024 by Aftab Amjad
Hi, I am trying to download a video from url and save it in the internal app storage which can be viewed in the Downloaded Fragment. The problem is that when i click the download button video starts downloading and in notification bar downloading...
15 Mar 2024 by Tyler Bakeman
Personal Project: I am new to Maven and have spent a few weeks troubleshooting pom errors with chatGPT. Tutorials are hard to come by online, because annotation-processing in Java is more complicated than the sources I've found. Issue in summary:...
15 Mar 2024 by joaoandreav
Looks like the file path might be wrong, or the resource handling needs work. Also, ditch .block() and handle things asynchronously. Double-check the file path and make sure it points to the actual file. Verify your resource and check server logs...
14 Mar 2024 by Pete O'Hanlon
Assuming that these are separately deployed services, I wouldn't attempt to start them from a central location. What I do is deploy my services in separate containers (Kubernetes on my part, but you could use Docker), and use orchestration to...
14 Mar 2024 by Office Systems
I'm having different micro-services such as configuration service, service registry, order service, customer service, payment service, front-end service, these services they fetch their configurations from config server and they are all connected...
13 Mar 2024 by JudyL_MD
Code sample for passing encrypted compressed data between Windows and Android
10 Mar 2024 by Pete O'Hanlon
As I don't know what Order looks like, I'm going to make some assumptions in this answer. The big assumption I'm going to make is that you have an Integer id value in the class, which I can get using getId();. I'm also going to assume that the...
10 Mar 2024 by Office Systems
I have two arrays which both have data, what I want to do is to loop through each array and compare the data between the arrays one array is coming from the Post Method and another array has data from the database, so the comparison has to be...
8 Mar 2024 by Han Bo Sun
This is a more in-depth tutorial on integrating Lucene search and index engine in Java applications.
27 Feb 2024 by UT7
Hello everyone, please I can't get SpringMVC project to create a table in MySql database. My entity class is below. @Entity @Table(name="customer") @Data @NoArgsConstructor public class Customer { @Id @GeneratedValue(strategy =...
27 Feb 2024 by Office Systems
I have created a spring boot application of version 3.2.2 which is going to act as a gateway service, the challenge I'm facing at the moment is that whenever I try to add hystrix dependencies for monitoring and for dashboard visualization of up...
21 Feb 2024 by Caroldoria Harris
The cost to ship a package is a flat fee of 75 cents plus 25 cents per pound. 1. Declare a constant named CENTS_PER_POUND and initialize with 25. 2. Get the shipping weight from user input storing the weight into shipWeightPounds. 3. Using...
20 Feb 2024 by Patrice T
Quote: What am I missing? I have tried so many ways to solve this. Not your problem, but: All these int shipCostCents = 0; final int FLAT_FEE_CENTS = 75; final double CENTS_PER_POUND = 25; are cents. Why are you mixing data...
20 Feb 2024 by CPallini
Replace Quote: final double CENTS_PER_POUND = 25; shipWeightPounds = scnr.nextDouble(); with final int CENTS_PER_POUND = 25; shipWeightPounds = scnr.nextInt();
19 Feb 2024 by developer new 2024
Hello, need help in solving an issue in code while uploading a file using webclient in Java as i keep getting errors. The code I tried: The code I tried returns error 'end of file never reached'. I have tried several solutions like converting...
16 Feb 2024 by OriginalGriff
We can't answer that based on a single line of code in isolation. Best guess? A spurious (or missing) close curly bracket. Start with the whole error message, and it will tell you where to begin looking. This should help you understand what the...
16 Feb 2024 by Munashe Gladson
orphaned case case 4: What I have tried: orphaned case case 4:
10 Feb 2024 by M-Badger
Google and ChatGPT/Bing Copilot are your friend. Google Java Swing | Create a simple text editor - GeeksforGeeks[^] Build your own text editor in Java | Opensource.com[^] java-text-editor · GitHub Topics · GitHub[^] Bing Copilot Sure, I'd be...
10 Feb 2024 by OriginalGriff
We can't answer this specifically: we have no idea of your skills, abilities, experience, or the environment in which the app should run - and how and where you start will depend on all those things. So all we can do is give generic advice: How...
10 Feb 2024 by Samar Khan 2024
I want to create a simple text editor using Java. I would also like to implement some features like auto completion and syntax highlighting. Any help is appreciated. What I have tried: I have not tried anything at all. I need some guidance
31 Jan 2024 by Richard MacCutchan
Take a look at Java Tutorials Learning Paths[^] and Welcome to Apache NetBeans[^]. Lots of useful tutorials and ideas, but also guidance on how to put things together.
31 Jan 2024 by OriginalGriff
We really can't tell you anything specific - it's a skill, and the only way to build a skill is through practice - you can watch as much of the Tour de France as you like, but it isn't going to teach you to ride a bicycle! :D Pick a subject that...
30 Jan 2024 by Srihari Vernekar
Hello there, i am facing a problem of not being able to build any useful projects. I have worked on learning concepts of OOP and also other basic concepts of programming and i have very well understood the concepts, but still lacks behind in...
21 Jan 2024 by Mike-MadBadger
The question tags java/javascript but your question includes a pointer (*str), I am therefore assuming that it is in fact C code. The answer would be different in java/javascript but the principle would be the same. You're not going to get...
21 Jan 2024 by OriginalGriff
While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for...
19 Jan 2024 by Office Systems
I have created Spring cloud config server to include all configurations of spring cloud config clients for my application, the problem is that my spring cloud config clients can not obtain the configurations from the spring cloud config server...
18 Jan 2024 by Pete O'Hanlon
The problem isn't in your code, rather the problem is with your deployment. You have stated that you deployed your application to Azure, and this brings its own set of expectations. Basically, the CORS request is being blocked by Azure, not by...
17 Jan 2024 by Bernardo Martinez
Hi I am a Digital weight scale yp200 braunker received from the RS232 port sends. Now I want to get this information in my application I want to display. The source does not anyone do this? C # language using the Serial port What I have tried: ...
17 Jan 2024 by Office Systems
I'm new to Micro-services architecture, I'm to develop a project using spring boot that gets data from API and stores that data into PostgreSQL db then computes and gets the sum of the data uploaded and sends that data into another database...
16 Jan 2024 by CPallini
You can also download the (Spanish) manual of the device, wherein the serial protocol is concisely described.
16 Jan 2024 by Graeme_Grant
You need to do research via Google Search. To get you started, here is the question I asked it: c# example of reading values from the Digital weight scale yp200 braunker[^] ... there are a few results Here is a helpful answer, but not for that...
14 Jan 2024 by Member 15226818
I wrote a sample code to work with the log4j library, but I encountered an error as mentioned below. Additionally, a new log4j file isn't being created. Can anyone help me understand why this error is occurring? What I have tried: This is my...
9 Jan 2024 by Member 16179780
👁 function togglePassword(obj) { ...
3 Jan 2024 by mickohan
Friends, I am able to unmarshall signature block for most of the cases with below code. However its failing to unmarshall for STRTransform case. Can someone guide me? Exception: Exception in thread "main" javax.xml.crypto.MarshalException:...
3 Jan 2024 by Łukasz Bownik
Smallscript is a little scripting language inspired by Smalltalk syntax.
2 Jan 2024 by Office Systems
I'm trying to create Micro-services architecture using spring boot, the only challenge I'm facing at the moment is how to configure spring cloud client to pull all the configurations from the config server, the config server gets all the...
29 Dec 2023 by Andre Oosthuizen
In Java, you can do something similar by using the 'CardLayout' for switching between different panels using Java Swing method. Example code - import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import...
28 Dec 2023 by NoName900
i'm coding a little java gui register project for practice. I've built the register Jframe and i want to move to a login Jframe by pressing a button. my question is, i remember in C# asp.net for example if you want to move to another page you...
24 Dec 2023 by Richard MacCutchan
See the Java Tutorials Learning Paths[^]
24 Dec 2023 by OriginalGriff
While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for...
24 Dec 2023 by Shahdoda
Do a project GUI in java that allows the user to add ,edit,delete information from table .the information is name,phone,email,address,gender, age,relationship and add validation Drag and drop What I have tried: Drag and drop...
24 Dec 2023 by Gerry Schmitz
With your design, you can't handle "collisions", because you're using "buckets". You can only "avoid" collisions by checking the bucket you "plan" to move to by first checking the bucket to see if it is "empty". You could wind up with a...
23 Dec 2023 by fs7schmitzii
This is a Fish Tank, where certain variants of fish can "swim" in. They move horizontal and vertikal (the vertikal movement is random). But one aspect is not covered yet. When two fish collide one fish just dissapears and never gets shown again....
23 Dec 2023 by Vishal Virmani India
packages com.jgoodies.looks does not exist .How to rectify this error in net beans .I am not able correct this even after downloading jgoodies.looks jar file and even after adding it to library .Can u plz correct this error What I have tried: ...
22 Dec 2023 by fs7schmitzii
I built a virtual aquarium. The problem on the one side is, that my moveFishes() method is really complex structured to the point, where I personally don't know how to structure it into different methods, while justifying, the program is still...
17 Dec 2023 by Dave Kreskowiak
This is where running the code under the debugger and stepping through the code line by line and inspecting variables would have helped you solve this faster than you could have typed the question into CodeProject. The problem is not about...
17 Dec 2023 by UT7
Hello everyone, I am using String.indexOf() to find all occurrences of a character in a string using a for loop. The problem is, I taught that if I iterate over the string in a for loop till the end of the length of the string the iteration...
17 Dec 2023 by Evgeny Pereguda
This article presents my project for capturing of video and audio sources on Windows OS by Microsoft Media Foundation.
14 Dec 2023 by ChristianNeumanns
The "absence of a value" is among the most important concepts a type system has to deal with.
12 Dec 2023 by M Imran Ansari
Instance variables are declared/defined in a class but outside the constructor (s), method(s) and block(s). For memory management, when memory is allocated for an object in a heap, a slot for each of the instance variables is created. Further,...
11 Dec 2023 by CPallini
See, for instance: Difference between Instance Variable and Class Variable - GeeksforGeeks[^].
11 Dec 2023 by Member 16128751
Attributes or Properties: Instance variables represent the attributes or properties of an object. For example, if you have a class representing a "Car," instance variables might include attributes like "color," "model," or "year." Scope: The...
11 Dec 2023 by Member 16161055
Memory Overhead : Each instance of a class with its set of instance variables consumes memory. If there are many instances with large sets of variables, it can lead to increased memory usage What I have tried: An instance variable is a variable...
11 Dec 2023 by Suhagkumar Vamja
The article discusses the challenges faced by businesses in releasing mobile applications quickly and the importance of faster time to market (TTM)
30 Nov 2023 by ChristianNeumanns
Union types (aka sum types, variants, choice types) provide an elegant solution for frequent programming tasks.
27 Nov 2023 by Pam04
getReplacementMap().put("regex...
25 Nov 2023 by Richard MacCutchan
No, we will not do your homework for you. It is your assignment to test your learning, not your ability to cheat.
25 Nov 2023 by Patrice T
Quote: How do I regex a string that contains forward slases The problem is not necessarily where you think it is. Use tools to see what part of RegEx matches what part of string, you may find surprises. Just a few interesting links to help...
24 Nov 2023 by Andre Oosthuizen
You can achieve your goal by simplifying it all - Remove unnecessary angle brackets, simplify the character class for your directory and file name, still included the dot '.' in the character class for your file extension -...
24 Nov 2023 by Pam04
Hello, I have a file hashname path generated in my tests as below. It has '/' for directory path, underscore and hyphens in random positions in file name. I want to replace this entire path using regular expression in my JPO. What I have tried: ...
24 Nov 2023 by Manish Kumar 2021
Can you try this getReplacementMap().put("regex:[^/]+/[a-zA-Z0-9_-]+[_-]+[a-zA-Z0-9_-]+[^.]+\\.[a-zA-Z0-9]+", "");
22 Nov 2023 by M Imran Ansari
Check this solution. Find a string using regex with forward slashes in it[^] Further, you can use this link to generate and test your regular expression. RegExr: Learn, Build, & Test RegEx[^]
22 Nov 2023 by Suhagkumar Vamja
In this article, we learn about Playwright, how it works, and why it is a good choice for web automation with Java.
21 Nov 2023 by UT7
Hello everyone, please I was trying to create a Spring boot project from eclipse IDE and I got this error - 'Import Getting Started Content' has encounter a problem. NoSuchMethodError: 'void ...
16 Nov 2023 by Dave Kreskowiak
You don't. The site does not allow uploading projects. That would take a lot of disk space and can easily be abused by those who are not trusted. You have to paste the code snippets relevant to the problem, not the entire file(s).
16 Nov 2023 by Krish The Great
Being a beginner,I am having a lot of problems(errors and exceptions) in my java project. How do I share the project here(the files)? What I have tried: I am a beginner is Java oops programming and not able to figure out few problems in my...
12 Nov 2023 by ChristianNeumanns
This article explains why we need native record types, and how they work in PTS.
12 Nov 2023 by Andre Oosthuizen
You have not initialized the 'next' node in your constructor, you can set the 'next' to null. This way, when you create a new 'ListNode', the 'next' field is set to null by default - class ListNode { int data; ListNode next; public...