online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
// Online Java Compiler // Use this editor to write, compile and run your Java code online import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Comparator; import java.util.Date; import java.util.List; public class Main { public static void main(String[] args) { List<YourObject> yourList = new ArrayList<>(); // Add objects to yourList YourObject obj1 = new YourObject(); obj1.setDateString("2023-09-01"); YourObject obj2 = new YourObject(); obj2.setDateString("2022-07-02"); YourObject obj3 = new YourObject(); obj3.setDateString("2021-08-06"); yourList.add(obj1); yourList.add(obj2); yourList.add(obj3); // Sort the list based on the string field "dateString" using Java Stream API yourList.sort(Comparator.comparing(obj -> { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); try { Date date = dateFormat.parse(obj.getDateString()); return date; } catch (ParseException e) { e.printStackTrace(); } return null; })); // Print the sorted list yourList.forEach((obj -> System.out.println(obj.getDateString()))); } } class YourObject { private String dateString; public String getDateString() { return dateString; } public void setDateString(String dateString) { this.dateString = dateString; } // Add other fields and methods as needed }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue