Click here to Skip to main content
15,886,788 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 Score

Java8 

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.
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.
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
19 Jul 2016 by Puja Jagani
Spring Hibernate Integration along with JTable widget.
19 Jul 2016 by Puja Jagani
Using jTable instead of drop-down list.
1 Jul 2022 by 0x01AA
***Warning*** This is my first java application after a crash course today. Take care, it is a.) inefficient b.) no naming conventions c.) simply fast and dirty But it shows the at least the steps how to build a sine sound. I have also cross...
10 Mar 2024 by Pete O'Hanlon
You're almost there. All you have to do now is fill in the calculation part. That's a simple problem that shouldn't take you long. To help, I will remind you what the calculation is. An Armstrong number is a number which is equal to the sum of...
2 Jul 2014 by TheCannyCoder
Introduction to functional programming in Java 8
14 Aug 2014 by TheCannyCoder
Reductions and Short-Circuiting Operations
18 Jan 2015 by mrcellux
FluentJdbc Query API for more convenient native SQL querying
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
17 Jul 2016 by Andy Point
Android Download Manager Tutorial: How to download files using Download Manager from the Internet
26 Oct 2016 by CPallini
You chose the wrong implementing class, the priority queue, well, prioritizes some inputs with respect others (in your case uses alphabetic order as priority criterion).Using, for instance the LinkedList implementing class, you could obtain the expected output:import...
19 Feb 2020 by Łukasz Bownik
A fluent JDBC wrapper written in 200 lines of code
27 Jun 2019 by CPallini
Replace Quote: sum=sum+(int)ch[i]; with sum = sum + (int)(ch[i] - '0');
27 Jun 2019 by Maciej Los
What you're doing in your code is converting char into ascii code and then getting the sum of them. That's why your result is equal 202, not 10. Check this: How can I convert a char to int in Java? - Stack Overflow[^] Quote: char x = '9'; int y = Character.getNumericValue(x); //use a...
25 Jul 2019 by Richard MacCutchan
Yes, serialization is the answer. You would need to save all details of each object in some permanent storage. When your application starts it should check fo the existence of the objects and deserialize them to their original form. See serialization java - Google Search[^].
24 Jun 2020 by Afzaal Ahmad Zeeshan
In Java, you can catch checked exceptions (such as the one you are facing right now) in a try...catch block as suggested in Solution 1: // try...catch only needs to be around the error-prone code. try { export(result); } catch (Exception...
2 Dec 2021 by OriginalGriff
Quote: Please ... and provide efficient code for this problem 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,...
27 Jun 2022 by 0x01AA
The pragmatic approach ... ... as soon this works one can think about to optimize it (e.g. loops instead of creating 10 Seconds of the same shape, stereo, etc.). You like to play a sinus- sound: Duration : [Sec] SampleFrequency : [Sample...
17 Oct 2023 by Dave Kreskowiak
You said it's a LARGE Excel file. The problem isn't really going to be the library you use, but the size of the file you're doing work on. Unless you reduce the size of the file, or import it into some other data structure, you're going to have...
13 Dec 2014 by Unihedron
I have this class:package com.gmail.inverseconduit.jchatexchange.assets;import jchatexchange.util.User;public class UserFactory implements jchatexchange.factory.Factory { private boolean cnu(User user) { [implementation dependant on #cnuz(User)] } private...
13 Dec 2014 by Thomas Daniels
You can use Lookup.unreflect[^]:public static void main(String..$) { Lookup myLookup = MethodHandles.lookup(); UserFactory foo = new UserFactory(); // test User baz = new User(); try { Method m = UserFactory.class.getDeclaredMethod("cnu", User.class); ...
17 Nov 2015 by CPallini
beacuseint x = 0;is variable declaration and initialization whilex = 0; is an assignment, not allowed there.
17 Nov 2015 by OriginalGriff
Um.You can't just put code into a class without it being inside a function body. Put the initializer in the class constructor and you'll be fine.
28 Nov 2015 by George Jonsson
Try to read about arrays and get an understanding about the topic.There is plenty of online material you can use.Examples:The Java™ Tutorials: Arrays[^]Beginning JAVA: Arrays[^]Multidimensional Arrays[^]If you check out the links above you might actually learn something. :-)
27 Jan 2016 by ZurdoDev
First off, you tagged this as Java but then asked how to do it in .Net. Java and .Net are 2 very different things. Secondly, creating a barcode scanner is not an easy thing to do nor is someone going to give you all the code to do it. You're talking about image recognition which is a very...
5 Dec 2016 by Richard MacCutchan
public static void setStat() { }Class.setStat().attack(5);No that will not work, because setStat does not return anything. In order to call a sub-method setStat needs to return an object reference.
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...
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...
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.
4 Jun 2017 by Richard MacCutchan
The message is telling you what line the error occurs on, and what the problem is. Go to line 20 and look at the statement; where is the definition of WhiteHouseTour? Your time would be better spent working through the Java Tutorials, which Google will find for you.
3 Aug 2017 by Richard MacCutchan
Windows services do not run in a session which has access to a terminal (desktop). That is to say no screen or keyboard (logical or physical) is attached. So bottom line is you cannot do this from a service. And, to be honest, that is just as well as such a feature would open a huge security...
23 Jan 2018 by OriginalGriff
It's not so much a case of "how do I do this?" as "why are you trying to do this?" Even as 32 bit integers (as Dave says) that's 4GB of data which is a spectacular amount for a single object. And if this is a mobile app (as is quite possible, given it's Java which is mostly used for Android) I'd...
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...
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[^]
27 Apr 2018 by Member 13797506
Introduction to structs (value types) in Java
6 May 2018 by Rick York
This would be my algorithm : for each n in array : if array[n] is zero then move all items in array after n forward set last item in array to zero //(ie., array[last] = 0) endif endfor The function memmove is handy for moving blocks of memory.
31 Aug 2018 by Jochen Arndt
Start here Microsoft JDBC Driver for SQL Server | Microsoft Docs[^] and follow the links. Some are Step 1: Configure development environment for Java development | Microsoft Docs[^] and Using the JDBC Driver | Microsoft Docs[^]. From the latter: Quote: The Microsoft JDBC driver jars are not...
10 Apr 2019 by CPallini
It looks your ArrayList needs serialization. See, for instance How to serialize and deserialize ArrayList in Java - HowToDoInJava[^].
30 May 2019 by OriginalGriff
Java is case sensitive: "person" and "Person" are different identifiers: public class Person { ... } class Student extends person { ... } Fix that, and other errors may disappear at the same time...
27 Jun 2019 by OriginalGriff
Well ... you could take advantage of the character set order, which has '0' then '1', '2', ... '9' in that order. So subtracting '0' from each character will give you the value: import java.util.*; public class Main { public static void main (String args[]) { String no = "1234"; ...
5 Jul 2019 by OriginalGriff
Look at your code: for(i=0;i
28 Oct 2019 by Richard MacCutchan
Use the CSVParser class to read the records and the CSVPrinter to write out the updated values. The documentation at org.apache.commons:commons-csv:1.7 api doc - javadoc.io[^] contains the class details and samples.
19 Jan 2020 by Patrice T
Quote: the result set has no current row. May be you should check the number of records in result. Advice: Never calculate a next id by your code because one day or another, 2 users will create a new id at same time anf you will end up with 2 records with same id. Let the server handle it for...
20 Jan 2020 by Richard MacCutchan
ResultSet rs = s.executeQuery("SELECT Car_No FROM CarRegistration"); rs.next(); You are assuming that the resultset contains some data. You need to check first whether any rows are present.
22 Jan 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 to do it all for you. So we need you to do the...
22 Jan 2020 by phil.o
You may reconsider your answer, because ^ is the bitwise XOR operator in java, not the power operator.
13 Feb 2020 by phil.o
This SO post may help you: How to print chinese characters to the windows console correctly?[^] Technically, there is nothing you can do from code; this is just a matter of Windows Console's configuration.
13 Feb 2020 by Dave Kreskowiak
You might want to watch the video by Scott Hanselman on this very topic: Computer things they didn't teach you in school #2 - Code Pages, Character Encoding, Unicode, UTF-8 and the BOM - Scott Hanselman[^]
18 May 2020 by phil.o
I think you are missing some double double-quotes at then end of your command string. Moreover, I am not sure about the double cmd / start chaining, you may be overthinking the whole thing. Tryprocess = runtime.exec("cmd.exe /C \"cd...
2 Nov 2020 by Gerry Schmitz
The problem is, you don't know how to write "generic" code. The "pattern" here is that you're using letters of the alphabet and you should be able to create a "loop" that steps through the alphabet and does it's thing with some "common letter...
21 Nov 2020 by Patrice T
Do yourself a favor and remove wrong language tags. Quote: Why does WHILE loop without break statement in recursion function works like infinite loop ? This is what you requested in your code. The best to understand what you did, is to watch...
18 Feb 2021 by OriginalGriff
No, Integer is a primitive - a value type rather than a reference type. Introduction to Java Primitives | Baeldung[^] So the == operator compares the content, not the reference, because there is no reference to a primitive! You can prove this...
28 Mar 2021 by CPallini
In Java methods, arguments are passed by value, so the al = noPrime; statement, inside the solution method, has no affect on the calling code. One possible fix is // ... (as before) public static ArrayList ...
21 Apr 2021 by Richard MacCutchan
Try this: public static void reversearray(int[] a, int n) // method does not return a value { StringBuilder sb = new StringBuilder(); for(int i=0; i
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...
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...
26 Aug 2021 by OriginalGriff
First off, why are you passing strings containing dates? If they fail to parse, there is no way to be "graceful" about it, or specific in what problem gets reported to the user. Assuming that the strings are user entered dates, you need to parse...
29 Nov 2021 by OriginalGriff
The null checks are there for a reason - to make sure that there is a User, that the user has an Address, and the address includes a State - without these, there is no information to process - and the null return is the way the method tells you...
3 Dec 2021 by Stefan_Lang
The algorithm requires you to access elements at random positions. This make both stack and queue (in case you considered that) a bad choice, because they only allow you to access elements from the end(s)! Furthermore, the algorithm requires you...
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,...
6 Jan 2022 by Richard Deeming
Quote: The condition was to show "Invalid number of elements" when the user enters a negative value. Then don't you think you should actually do what you were told, instead of blindly accepting the input and trying to create an array with a...
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
11 Jan 2022 by CHill60
We do not do your homework for you. It doesn't help you. It just means that you will have even more problems with your next assignment because your tutor will assume that you understood this particular one. Write a Java program that 1. Takes...
11 Jan 2022 by Patrice T
You are learning and homework is training, nobody can do it for you. Do you think Usain Bolt asked someone to train for him when he was a beginner ? You show no attempt to solve the problem yourself, you have no question, your main effort is...
12 Jan 2022 by OriginalGriff
See here: Java String.equals() Method[^]
12 Jan 2022 by _Asif_
Here is the Tip for you. Some of the search complexities have been ignored intentionally. * Build a Class "Designation" * Designation Class should have Two Attributes. DesignationType and DesignationName * Take Number of Designations as Input...
23 Jan 2022 by Tony Hill
You added a line that will check that the string elements of the p1 instance of the Customer class for null but you have not added a check for the string elements of the this instance class. @Override public bool equals(object obj) { if (obj ==...
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...
21 Jul 2022 by CPallini
[fixed, thanks to zemiak123] You may use the String.indexOf[^] method. Try static String untilChar(String strIn, int chr) { int index = strIn.indexOf(chr); if ( index != -1 ) { strIn = strIn.substring(index); } ...
26 Sep 2022 by Dave Kreskowiak
That's a lot of code just to do this: byte[] buffer = File.readAllBytes(filepath); Yeah, I get it. The entire file is going to be pulled into memory and could run the machine out of RAM. But for a test project just to learn how to parse the...
5 Oct 2022 by Dave Kreskowiak
Think of your "question" this way. You just walked into your job and asked everyone else to do all of your work for you. Congratulations! You just got yourself fired from the that job.
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...
6 Feb 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...
5 Mar 2023 by OriginalGriff
Try this: Convert XML to JAVA Object Online - Json2CSharp Toolkit[^]
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",...
4 Feb 2024 by OriginalGriff
As Richard has said, it's going to depend on the data processed, and we have no access to your file system - the debugger is (as always) your best friend here as it can show you exactly what is going on while your program runs. So, it's going to...
30 Jun 2015 by Bobby Lough
An coding exercise using Java 8 trying to do the same summation loop multiple ways
31 Aug 2015 by Mehdi Gholam
Search for "HID protocol using java" in Google you will get your answer : https://www.google.com/search?q=HID+protocol+using+java&ie=utf-8&oe=utf-8&client=ubuntu&channel=fs&gws_rd=ssl[^]
14 Oct 2015 by hasnain_ahmad
I am using java 8 date and time classes in my code. I can find year, month, day, hours, minutes and seconds, but I cannot find a method to find a number of days in a month.Here is my code.String oldestDateString = "2015-10-01 00:00:00";String latestDateString = "2015-12-25...
14 Oct 2015 by Richard MacCutchan
You can find the number of days in a month by creating a datetime object for the first day of the following month, and subtracting 1 day. That will then be adjusted by the class object to the last day of the previous month. I'm not sure what you mean by How can I iterate through “oldestDate”...
12 Nov 2015 by prashant singh
What is finalize() method in java programming. Please explain when and why it use.
12 Nov 2015 by OriginalGriff
Google is your friend: Be nice and visit him often. He can answer questions a lot more quickly than posting them here...A very quick search using your subject as the search term gave over 400,000 hits: Google "What is finalize() method in java programming"[^]In future, please try to do...
17 Nov 2015 by prashant singh
my code is this:class first{ int x,y; x = y = 0;}class second{ public static void main(String args[]){ first x = new first(); System.out.println(x.x); System.out.println(x.y); }}Error: exceptedx = y = 0; ^When I write this code like this:class...
29 Nov 2015 by prashant singh
Why we can not assign value to array like this-int array[][]=new int[3][3];array[][]={ {1,2,3}, {4,5,6}, //invalid {7,8,9} }; why we need to assign value separately like...
3 Dec 2015 by George Jonsson
If you want samples, just use Google and you will find plenty of help.Java - Loop Control[^]The Java™ Tutorials: The for Statement[^]
4 Dec 2015 by jagdish vaghela
i am beginner in java programing so i dont khow about the null pointer exception please any body help me how can i solve this type of error-i have two class one with name Student.java and another with SrDemo.java-i write gatter satter in Student class and use this is SrDemo class But when i...
4 Dec 2015 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 method return value but it contains null -...
4 Dec 2015 by phil.o
Most probably because you are declaring an array but never initialize it.Here:Student sd[]=new Student[2];sd[0].setName("name");should read:Student sd[]=new Student[2];sd[0] = new Student();sd[0].setName("name");Debugging is definitely the way to spot this kind of...
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...
16 Feb 2016 by rah_sin
Kindly set the class path of jar having GUI.Home classproperly
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.
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...
23 Aug 2016 by User 12615978
It is for fix withdrawl but my test cases are failing.What I have tried:import java.util.*; public class save { public static void main(String args[]) { double Money = 0, principle_amount, Interest_rate = 0, Amount, n; int Time = 0, Actual_amount_need; Scanner sc =...
28 Jul 2016 by Member 12659413
public class Compress { public static void main( String[] args ) throws FileNotFoundException { File file = new File("E:\\input.txt"); Scanner scanner = new Scanner(file); PrintWriter writer = new PrintWriter("E:\\sample.txt"); ...
28 Jul 2016 by Mehdi Gholam
Read this : Remove end of line characters from Java string - Stack Overflow[^]
19 Aug 2016 by Member 12693837
What I have tried:class add{ // public int g; // public int d; public static int a(int g,int d){ //int h =g; //int s =g; return g+d; }}add d = new add;