Click here to Skip to main content
15,893,508 members
Everything / Programming Languages / Java / Java8

Java8

Java8

Great Reads

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 Pritam Zope
In this article, we will create a notepad in Java with features like Multi Tabbed Documents, Document Selector, Openning/Saving/Closing Multiple documents, Running External Programs,Different Look and Feels, Viewing files in Browser, etc.
by Andy Point
Android Alert Dialog Tutorial : Working with Time Picker, Date Picker and List Dialogs In this tutorial we will discuss how to use dialogs and alerts in Android Apps. A Dialog is a small popup shown to the user to get some additional information from the user or ask him to make some decision. Alert
by Puja Jagani
Spring Hibernate Integration along with JTable widget.

Latest Articles

by stevenong_2006
How to install/configure the Artemis on the Linux Ubuntu 18.04.x OS
by Łukasz Bownik
A fluent JDBC wrapper written in 200 lines of code
by Bilal N Gharib
This article is about automatic resizing of a frame and its controls with the same ratio in Java.
by Sidd Gautama
Declarative, Configurable and Super Easy API testing lib using YAML/JSON steps

All Articles

Sort by Title

Java8 

10 Jul 2021 by johnathan indigo
public class AddressBook { private String[] firstNames = new String[1000]; int firstNameCount = 0; private String [] lastNames = new String[1000]; int lastNameCount = 0; private String[] addresses = new String[1000]; int...
10 Jul 2021 by OriginalGriff
Well, it's not C. Or Python. Or Javascript. And that's three already ... After that ... it looks like student grade code - which isn't a compliment; it uses magic numbers that aren't explained; it's never head of the modulus operator; the method...
10 Jul 2021 by KarstenK
In my mind the worst problem is, that you want to cheat by letting other help you to solve your homework. Bad is ofcourse the use of the "magic numbers" 2 and 1000 and no check for the file input. I personally hate to name a string "bit".
8 Dec 2021 by Member 15435322
I know @JsonProperty annotation can be used in the class of instance fields,which means in the view section what I want to show variable name, it is okay, but what if what annotation do we have to use to show the name of the class as I want in...
2 Feb 2017 by Member 12980589
How can I complete this classification program. I would like to add element to corressponding array list.public class Classification { private ArrayListinteger = new ArrayList(); private ArrayListDouble = new ArrayList(); private ArrayListstring = new...
2 Feb 2017 by CPallini
Quote:public class Classification {Since your class should classify passed data, it makes no sense making it dependent upon a generic parameter.Quote: private ArrayListinteger = new ArrayList(); private ArrayListDouble = new ArrayList(); private ArrayListstring = new...
7 Sep 2018 by Member 13124677
Hello and good evening, I've just started Java/programming two days ago and I seem to struggle with nested if/else statements. I've provided my current 'project' down below. The if statements when female works just fine, but the male statements always gives out both the possibility with Mr and...
12 Apr 2017 by Dave Kreskowiak
This sniffs of homework so I'm going to blurt out an answer, but look at your curly braces and make sure every closing brace is matched up with an opening brace and the other way around.
7 Sep 2018 by Member 13976534
import java.util.Scanner; public class GenderAndMarigeStatus { // i made some changes and now is okey public static void main(String[] args) { Scanner s = new Scanner(System.in); String m = "Male"; String f = "Female"; String Married; System.out.println("What is your gender (male...
22 Oct 2016 by Member 12809433
I have some big long code from a group project I'm working on. We all add our own separate classes to an "Army" class that consists of a GUI showing each of our different classes (like "Archer, Ninja, Catapult, etc.).Anyway, I want to create an ArrayList that records each of the objects...
22 Oct 2016 by Member 12809433
Turns out I couldn't call methods (like the .add() method) from directly within the class, not in a method. Problem solved :/
28 Aug 2016 by Andy Point
Today Almost all web and mobile apps come with Google and Facebook Login, This is a really useful feature for both the app developer and the user, since almost everybody tend to have a google/gmail and facebook account and moreover while logging in with google you don’t need to remember your UserId
9 Aug 2021 by Lucius Raleigh
Currently I'm having a problem that I don't know how to solve. It's the decryption and encryption of the string using AES256. Everything was working fine until I restarted the server and I couldn't decode the previous data. Hope everyone can help...
9 Aug 2021 by OriginalGriff
You are using a random number generator to produce your IV when you encrypt your data : unless that exact IV is used when you decrypt it, what you will get is nonsense. So every time your app is closed, the current IV is discarded and when it is...
18 Jul 2016 by Andy Point
Android Alert Dialog Tutorial : Working with Time Picker, Date Picker and List Dialogs In this tutorial we will discuss how to use dialogs and alerts in Android Apps. A Dialog is a small popup shown to the user to get some additional information from the user or ask him to make some decision. Alert
17 Jul 2016 by Andy Point
Android Download Manager Tutorial: How to download files using Download Manager from the Internet
17 Jul 2016 by Andy Point
Android Flash Light Application Tutorial Using Camera2 API
17 Jul 2016 by Andy Point
Android Material Design: Working with Floating Label EditText
1 Aug 2018 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.
2 Dec 2016 by Tung.Nguyen.2k
How to implement B-Tree's searching, insertion and deletion in Java
30 Oct 2018 by WalterCC
Hello! I am having an hard time with a code from my teacher book. In the Code I must display the divisors. I get this error: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at Display.main(afisare.java:7) I am really frustrating , can you help me ? Here code: class...
30 Oct 2018 by Member1x
Ty changing your code from public static void main(String args[ ] ) to public static void main(String[] args) That should solve the problem.
29 Mar 2016 by Giancarlo Rhodes
ORM objects and basic CRUD operation procedures are first phase tasks that come after establishing a first version of the database. This java-based code generation tool builds those classes and stored procedures.
19 May 2018 by Patrice T
Quote: I am still a beginner and I haven't got the problem statement till yet. There is something you don't tell, either you are not a beginner, the assignment is not your level, or you just want us to do your HomeWork. Quote: Can help me with the solution to this problem. So, you show no...
5 Apr 2018 by Vijay Krishnegowda
class test{ public static void main(String args[]){ b ref=new b(); ref.x=99; ref.show(); }} class a{ int x=10;} class b extends a{ void show(){ a ref=new a(); System.out.println(super.x);}} What I have tried: when i compile i am getting answer as 99 but i am not understanding ?
5 Apr 2018 by Patrice T
Quote: when i compile i am getting answer as 99 but i am not understanding ? Your code do not behave the way you expect, and you don't understand why ! Use the debugger and see by yourself: There is an almost universal solution: Run your code on debugger step by step, inspect variables. The...
5 Apr 2018 by CPallini
Class b inherits x data member from class a. Your code assigns it and then prints its value. No surprise the output is 99, I have to say. Please note, in the below codeQuote: void show(){ a ref=new a(); System.out.println(super.x);} the statement a ref=new a(); has NO effect: you are...
29 Dec 2015 by Member 12235902
if i can program an operating system in java, can you give me push to that wayI have experience in java and I coding network programsso what you advice me..
30 Dec 2015 by Duncan Edwards Jones
Not really - because java runs on a JVM which in turn runs on top of an operating system.You could write a kernel in another language then write the rest of the "operating system" on top of that..Take a look at OSDev Wiki[^] for all aspects of developing an operating system to get you...
24 Mar 2018 by nidhi01
Below code is of git push command through java everything if I run without using try catch block it successfully pushing the files, But im not getting that how to throw error if user enter wrong url and username and password by using try and catch block can anyone do correct edit in the code for...
10 Dec 2022 by CodeGuru84
Yes, you can have an array of object type in Java. An array in Java is a container that holds a fixed number of values of a single type. The type of an array can be an object type, such as Object, or any other class type. For example, the...
18 Jul 2023 by Vibhanshu 2022
Object[] array = { 1, 2, new Object[]{ 3, 4, new Object[]{ 5 }, 6, 7 }; Integer[] flattenedArray = flatten(array); //My function flatten(array) takes Object[]inputArray and returns it into flatten array of type ``` public static...
23 Sep 2023 by Member 16099189
public static Object[] flatten(Object[] arr) { Stream stream = Arrays.stream(arr); stream = stream.flatMap(o -> o instanceof Object[] ? Stream.of(flatten((Object[]) o)) : Stream.of(o)); Object[] flattenedArray =...
13 Apr 2018 by Member 13276583
public class Math { public static void compare(String A, String B) { int a; a= S.replaceAll("[^" + J + "]" , "").length(); String b = S.replaceAll("[^"+ J +"]", ""); System.out.println(a is +a); System.out.println(b is +b); } public static void main(String[] args) {...
13 Apr 2018 by Richard MacCutchan
It means all characters that are not in the set in brackets. So [^abc] means any character except a or b or c. See RegExr: Learn, Build, & Test RegEx[^]
12 Apr 2022 by Sourabh Jambale
This is the implementation class where i've implemented a regex to check correct password: class Implementation { public String passwordValidator(Credentials details) throws WeakPasswordException { String a = "[A-Za-z][A-Za-z0-9]+";...
12 Apr 2022 by Richard MacCutchan
OK, I managed to test this and your regex patterns are incorrect. Pattern a accepts any alphabetic character followed by any alphanumeric character repeated a number of times. Pattern b accepts any alphanumeric character repeated between 8 and 41...
19 Jul 2016 by Puja Jagani
Extending the functionality of jTable.
6 Mar 2017 by Member 13041847
I have been asked to create a class with Attributes name, Stringjob, String roles[], Array of Strings that identifies the rolesof people Constructors:• public Office(String job)• public Office(String job, Stringroles)All Getters and setters for all the...
6 Mar 2017 by OriginalGriff
We dont; do your homework for you - you wouldn;t learn much, if anythign, if we did!So ... time to start reading: Arrays (The Java™ Tutorials)[^]Because java arrays are a fixed size, you will need to maintain an index of teh "next free element" for your roles array. You can add an item by...
6 Mar 2017 by Richard MacCutchan
See The Java™ Tutorials[^].
6 Mar 2017 by Patrice T
We do not do your HomeWork.HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them. Any failure of you will...
14 Aug 2014 by TheCannyCoder
Reductions and Short-Circuiting Operations
10 May 2022 by salam_verdim_alana_panyatkasi_olana
Hi guys. I wondering a thing, which is there any future of programming language, which when we run our app and to see that where happened our error? For example if we assign string to integer it is easy that detect our error, but runtime it is...
10 May 2022 by Patrice T
Quote: if we assign string to integer it is easy that detect our error, but runtime it is difficult. May be time to break the debugger. Your code do not behave the way you expect, or you don't understand why ! There is an almost universal...
10 May 2022 by Greg Utas
You tagged this as a Java question. Java is typed, so assigning a string to an integer isn't possible. Most software errors are logic errors. The software isn't doing anything illegal. It's just not doing what you intended, but there's no way to...
11 Aug 2020 by OriginalGriff
We are more than willing to help those that are stuck: but 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 us...
7 Nov 2020 by Premnath Kamalanathan
I am trying to use the stream API to convert my flat object list to a hierarchy. I tried to search for similar questions here, but I didn't find one that would work for more than one level as in my case I need it to work for 2 levels. My flat...
30 Aug 2022 by T1xT
A generated sine sound data are stored in a byte array: double SAMPLE_RATE = 44100.0; double AMPLITUDE = 32768.0; double timeSeconds= 10; int shortBufferSize= (int) (timeSeconds * SAMPLE_RATE); short[] shortBuf = new...
26 Mar 2023 by vor_zakon_developer
I am trying to convert String value to Long type but "0" value losing. For example I am converted this value: "032" --> but it converted only 32 What I have tried: I saw any example but it was not related to my problem.
26 Mar 2023 by CPallini
Short answer: you cannot do that, string leading zeroes are definitely lost. As a workaround (if you badly need it) you could maintain such a piece of information (that is the number of leading zeroes in a separate variable, and use it whenever...
26 Mar 2023 by Richard MacCutchan
Numeric values do not have (or need) leading zeros. The only time they are necessary is when you want to display or print the number, by the use of format strings. For example "%03d" as follows: int number = 32; System.out.printf("%03d%n",...
26 Mar 2023 by OriginalGriff
To add to what Richard and Carlo have said ... When you convert a string to a number, you aren't just stripping away leading zeros - you also convert the number to a value that the computer can understand: binary, stored in a fixed-size variable...
15 Apr 2021 by Ishmeet Kaur
rollNumberStream has String eg PE11115,HI34565,Pe5567,Pe5137,pe4324,EE21258 and I need to count number of people in specified department(Passed in arguments as dept) case insensitive. If pe is passed it should consider PE11115, Pe5137,pe4324 all...
15 Apr 2021 by OriginalGriff
Convert them both to lowercase before you compare them. Convert the dept before you start comparing, and use toLower in your lambda to convert x before calling startsWith
15 Apr 2021 by Ishmeet Kaur
String dept_lower=dept.toLowerCase(); long count_roll=rollNumberStream.filter(x->x.toLowerCase().startsWith(dept_lower)).count();
6 Oct 2017 by Member 13450482
Instructions create a simple CLI (command line interface) application. When we test your application, it must do three things: Welcome the user. Prompt the user for input. Respond differently to different input. Handle bad input and provide an exit option. For example (and please do not make...
6 Oct 2017 by Ravi Bhavnani
This[^] would be a good place to start. And CodeProject, we don't do your work for you.  We help you do your work.  Unfortunately, we can't help you learn Java and the basics of Java programming.  That's something you'll need to do yourself.  If you have a specific problem, we'd be glad to try...
15 Feb 2017 by Pritam Zope
In this article, we will create a notepad in Java with features like Multi Tabbed Documents, Document Selector, Openning/Saving/Closing Multiple documents, Running External Programs,Different Look and Feels, Viewing files in Browser, etc.
29 Jun 2019 by moga2003
Good morning, I have been working on a project for the last few weeks, and I cant seem to figure out what I am doing wrong. When I run the java files, it will not find the Displayable class. This is not the only file in the util package, and yet it is the only one it will not find. I am new to...
29 Jun 2019 by Richard MacCutchan
The Displayable.java file needs to define the Displayable interface, in order for the implementing class to import its definitions. Something like: Package until; interface Displayable { public String display() { // other code here } } // end of interface definition For more...
10 Nov 2021 by xcommunicado
Define a java program to write the student class into a file. Register number, course1, mark1, course2 and mark2 are members of the class. Get ‘n’ objects from user and write those into a file. Later, read those objects from the file and find the...
10 Nov 2021 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...
10 Nov 2021 by CPallini
The approach to this question could be: Write the student class as requested. The requirements are pretty clear and you may find tons of related examples on the web. Allow the user to insert objects of the student class. Again you may find...
26 Apr 2023 by Office Systems
How can I delete large amount of data more than 10 million records in fraction of a second in spring boot project, the code I'm having right now takes more than 1 minute and 30s to delete these records. Below is the code I'm using to delete these...
23 Jan 2018 by Member 13639093
Do packages provide encapsulation, if not what is the difference What I have tried: I'm in my first year programming class, and was taught Encapsulation is basically, hiding variables by making the access modifier private, but do packages basically do the same thing than ? I am unsure because...
8 Jul 2016 by JfxDev
I have a reproducible problem with the Mint Cinnamon desktop locking up when hitting a breakpoint debugging with Eclipse. When I say it's locking up, I mean mouse clicks are completely inoperable (even on the Mint panel). Alt-Tab looks like it's working, but selecting another window doesn't...
30 Mar 2023 by Office Systems
'm Creating a spring batch project and I have tried to create all the key components required for the spring batch to run but I'm getting the exception 'Error creating bean with name 'scopedTarget.patientReader' defined in class path resource'...
12 Aug 2022 by Navya Yanamadala
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; import java.util.*; public class Main.java() { public static String customerDetails[][]=new String[5][3]; Main() {...
12 Aug 2022 by OriginalGriff
Look at line 7: public class Main.java() { Class names cannot contain decimal points: "Main.java" is not a valid class name. The file extension is not needed as part of a class name. Classes are not methods: the "()" after a name indicates...
4 Oct 2018 by smorey
I am trying to add functionality for autocalculate button. I am getting null pointer exception. Can you please help in resolving this Result...
4 Oct 2018 by OriginalGriff
Two things: 1) Just dumping your whole app on us and saying in effect "you sort it out - I can't be bothered to even just cut it down to the relevant bits" is not a good idea. Remember we are all volunteers and you want help from us - so the better the information you give us, the better our...
10 Jan 2022 by Sourabh Jambale
I want to input a 2*3 String array from the user which contains details about the customer including their customer ID, their name and their city name. I want to sort according to their ID and display accordingly. But I'm getting the above error....
10 Jan 2022 by OriginalGriff
You declare the array as [2][3] - a total of six elements: String info[][] = new String[2][3]; Then you loop though each valid index: for (int i = 0; i
3 Feb 2021 by CaptainnLevii
I want extract key value pair from xml file in my java code. My XML element that contain key value pair : What I have tried: ...
12 Dec 2017 by Vladimir Kolmanovitch
The article allows extracting java.lang.reflect.Method using anonymous class or lambda
17 Jul 2016 by Andy Point
Firebase Android Tutorial : Adding Registration and Login Hello Developers, this is our android firebase tutorial. In this tutorial we will create an android firebase app that will use firebase android login functionality. This post will help you get you up and running with integrating Firebase to a
18 Jan 2015 by mrcellux
FluentJdbc Query API for more convenient native SQL querying
30 Sep 2018 by Member 14002156
How do I write a Java Program That prompts the user to enter a password and displays it back in the console window. The displayed password should be the entered password halved with the full password total number of characters added at the end. example1: enter your password: abcd your password...
30 Jun 2015 by Bobby Lough
An coding exercise using Java 8 trying to do the same summation loop multiple ways
29 Mar 2022 by salam_verdim_alana_panyatkasi_olana
Hi there, I am writing service consume where my consume service make the get request to given endpoint, but there is a problem, which I can not understand that how can I solve it? following link you can read documentation which I develop right...
1 Sep 2017 by Member 13389746
Hello, I need some help. I have a Java 1.8 test application that uses Selenium 3 and the Firefox Geckodriver. The tests work perfectly when I'm at work but fail when I'm trying to work at home. Since I work exclusively on a virtual machine, and have cloned the work virtual machine for my home...
1 Sep 2017 by Dave Kreskowiak
You're really only going to get guesses to this one since you've taken a work machine out of the environment it was design and configured to run in. My first guess, the browsers on the machine were configured to go through a proxy server at work, one which does not exist at home.
22 Nov 2020 by Member 14999696
Given a linear equation in one variable of the form num1 operator num2 = num3 where any one of num1, num2 or num3 is the variable x and other two are integers. Operators can be any one of +, -, / or *, there may or may not be spaces given between...
22 Nov 2020 by OriginalGriff
We are more than willing to help those that are stuck: but 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 us...
22 Nov 2020 by Rick York
step 1 : pick a language. step 2 : write logic to open and read a file. step 3 : write logic to parse the data read from the file step 4 : write logic to solve the problem from data parsed step 5 : write logic to output results Four of those...
9 Sep 2016 by Andy Point
Google Maps Search Nearby In this post we will learn how to find nearby places in Google Maps. We will first see how to get current location of user and then will add marker on nearby places like Restaurants, Hospitals, Schools etc. You can see demo of this post (Google Maps Search Nearby) in above
7 Dec 2021 by Member 15435322
I was wondering, what is the best way to create relationships between entities in a project that is being written from scratch, or specify what relationships to have between them? For example, as we can directly understand the relationship...
7 Dec 2021 by Afzaal Ahmad Zeeshan
Quote: create relationships between entities in a project that is being written from scratch, or specify what relationships to have between them? That's the best part about an ORM. You don't need to think about it yourself (apart from some index,...
16 Sep 2022 by Member 15769941
please explain how 0 0 9 98 is coming in the java method invoking the program. class Jtc2{ public static void main(String[] args) { int ab = 98; System.out .println("ab in Main Before\t:" + ab); Mno ref = new Mno(); ref.showValue(ab); System.out...
16 Sep 2022 by OriginalGriff
Getting your code to run does not mean it 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...
16 Sep 2022 by Richard MacCutchan
Because you are passing 0 to the recursive call: // assume ab = 9 at this point if (ab != 0) showValue(ab / 10); // i.e. showValue(0)
20 Oct 2021 by User 15041314
{ "message": "The operation was successful.", "code": 200, "fileDetailResponseDtos": [ { "phoneNumber": "550000000", "textMessage": "Message1", "createDateTime": "2021-10-20T15:45:27.277", "sender": "Anar", ...
6 Dec 2021 by Member 15435322
Suppose I am returning data like this in rest api: { name:"Ronald", age:25, salary:1500 } But what should I use to design variable names as I want? For example: { Name: "Ronald", Age:25, Salary:1500 } How can I design that only variable...
6 Dec 2021 by Gerry Schmitz
Quote: The schema helps in a multiple way. It acts as a contract between two teams, serves as a specification, simple to read and easy to follow and you can use it for validation once your APIs are ready. JSON Schema - as a specification,...
8 Jun 2017 by Member 13248960
My application needed two spinners appearing vertically parellel like a datepicker with date and month. I was trying to access the datepicker class object spinner, hide the year column and access the two columns. Can anyone help me on this.Thanks in advance. What I have tried: Field f[] =...
3 Jul 2018 by Member 13576671
Hello I have a webpage with a forms that when it submits, runs a servlet. In that servlet I need to know the webpage who calls the servlet. How can I do? I´m using Java 8. Thanks What I have tried: I try with several methods of HttpServletRequest, as getQueryString, getServletPath,...
3 Jul 2018 by MadMyche
request.getHeader("referer");
10 Apr 2019 by Member 14030302
I'm currently writing a command line app that takes input from a user through the terminal/command line and appends that data into an array list which is then appended to a text file. The user should be able to perform actions like filtering the contents by name, index, etc. For example, if the...