[Solved] How to delete item from array list Java eclipse

I advise you re write your code. One mistake to note, you are attempting to create objects of type List. List is not a class and cannot be instantiated, it is an interface that contains methods to be implemented but these methods contain no bodies. To use java.util.List, you must implement it and then implement … Read more

[Solved] Creating a loop from Java input

Although it’s not entirely clear what you’re trying to achieve I have tried to modify your code from your original post to make it more readable and function the way you want. Please see my comments in the code below, I tried to prefix all of my comments with “EDIT” so you could easily identify … Read more

[Solved] Is there an “onChange” for Java? [closed]

There is no generic onChange function. However there is a method you can define in a class that implements KeyListener which is public void keyPress. You would use this something like the following: public class MyClass implements KeyListener { private JTextField myField; private JLabel myLabel; public MyClass() { myLabel = new JLabel(“Enter text here”); myField … Read more

[Solved] get() or elementAt() in Java [closed]

First off, you didn’t tell us what data structure you are working with. So, I’ll go with the assumption that you are using Vector or some Vector derivative. The two methods are identical according to the documentation: http://download.oracle.com/javase/1,5.0/docs/api/java/util/Vector.html That being said however, elementAt(idx), dates back to the days when Vector did not follow the List … Read more

[Solved] Calendar order in java [closed]

use TreeSet, by implementing Comparator interface and providing reverse sorting logic and finally add all elements of HashSet to TreeSet using addAll() method of Collection interface. // using Comparator constructor argument of TreeSet TreeSet < String > ts = new TreeSet < String > (new Comparator < String > () { @Override public int compare(String … Read more

[Solved] where should i catch the exception???? main public method? or private method? [closed]

Though question seems to be very broad, but you need understanding on Java Exception framework + bit of design patterns 1.) If you are exposing some public methods in a service, it is always better to catch exception Log Exception -> Return proper error code/message 2.) throwing exception means everyone who is calling that method … Read more

[Solved] Parse Date JSON Object to Java

You can user java.text.SimpleDateFormat for this kind of purposes. String a=”2016-06-16 11:47:21.000000″; SimpleDateFormat sdf1=new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”); SimpleDateFormat sdf2=new SimpleDateFormat(“dd MMM yyyy”); Date date=sdf1.parse(a); System.out.println(sdf2.format(date)); 2 solved Parse Date JSON Object to Java

[Solved] Replace multiple substrings between delimiters in Java

From comment: but if I do not know the text between the delimiters? So it sounds like the replacement values are positional. Best way to do this is a regular expression appendReplacement loop: public static String replace(String input, String… values) { StringBuffer buf = new StringBuffer(); Matcher m = Pattern.compile(“\\|{2}(.*?)\\|{2}”).matcher(input); for (int i = 0; … Read more

[Solved] Class interface or enum expected – Error

Ciao Mario, I think you want an Android app able to do this. First of all you have Android Studio installed so in Android Studio click on File -> New -> New Project… and let’s create the project as shown here. Your project location will be different and it’s ok but if you don’t want … Read more

[Solved] Output of program unable to display correctly in Java [closed]

Its a basic integer divison problem Integer division: How do you produce a double? Either change int maxDays, days; to double maxDays, days; or change your calculate method from: attendancePercentage=(days/maxDays)*100; to: attendancePercentage = ((double) days / (double) maxDays) * 100;` solved Output of program unable to display correctly in Java [closed]

[Solved] How can I update the voice channel when a user enters the guild with JDA

To modify an entity in JDA you usually have to use the manager. You can acquire an instance of a manager through getManager() on almost every entity. TextChannel channel = guild.getTextChannelById(573629024102776853L); channel.getManager() .setName(“Total Users:” + guild.getMemberCache().size()) .queue(); // this is needed, otherwise the request won’t be made to discord If the id for the channel … Read more