About 189,000 results
Open links in new tab
  1. java - How to write an .add () method? - Stack Overflow

    Mar 13, 2013 · Another typo. Java is case-sensitive so "Inches" is not the same as "inches". Other than those, the getters/setters look fine. As for the add() method... There's no reason to create those "a", "b", "c" and "d" variables. int a = this.feet; int b …

  2. java - How to add new elements to an array? - Stack Overflow

    Mar 12, 2023 · Use a List<String>, such as an ArrayList<String>.It's dynamically growable, unlike arrays (see: Effective Java 2nd Edition, Item 25: Prefer lists to arrays).

  3. java - How to add description to method or class - Stack Overflow

    Jun 20, 2020 · You can use javadocs using /** comments */ For a method basically you can have /** The Desciption of the method to explain what the method does @param the parameters used by the method @return the value returned by the method @throws what kind of exception does this method throw */

  4. add an element to int [] array in java - Stack Overflow

    Apr 9, 2013 · Want to add or append elements to existing array int[] series = {4,2}; now i want to update the series dynamically with new values i send.. like if i send 3 update series as int[] series = {4,2,...

  5. Java Linked List - add method - Stack Overflow

    Second prepend fourth add First prepend Third add First add First Append Second Append Conclusion: "Second Add" is lost, as well as "Fifth add" and "Sixth add" because your next() method stops as soon as it reaches the tail. You need to always update the tail if you add a new node in the end. Hope this helps. Cheers, Chnoch

  6. Does Java support default parameter values? - Stack Overflow

    "A closure is a function that refers to a free variable in its lexical context." So here, in this case, closure is the returned function when operated on variable multiply and it has a free variable a that has the lexical context of the caller function. Return the multiply method or fix the default value for one of the parameters.

  7. Can I add a function to enums in Java? - Stack Overflow

    As well as using the techniques above which add a field to the enumerated type you can also use a pure method based approach and polymorphism. This is more "OOP style" but I would not say it is necessarily better. Unfortunately, you may (see …

  8. How to pass a function as a parameter in Java? [duplicate]

    To add on to jk.'s excellent answer, you can now pass a method more easily using Lambda Expressions (in Java 8). First, some background. A functional interface is an interface that has one and only one abstract method, although it can contain any number of default methods (new in Java 8) and static methods. A lambda expression can quickly ...

  9. How do I use optional parameters in Java? - Stack Overflow

    Jun 8, 2009 · Update: Java 8 includes the class java.util.Optional out-of-the-box, so there is no need to use guava for this particular reason in Java 8. The method name is a bit different though. The method name is a bit different though.

  10. java - add a function to JButton - Stack Overflow

    Apr 7, 2014 · i have 2 JButtons on my JFrame and i would like to add a function to it when i click on them.. I Would like the JButton calculator allow me to open another JFrame if thats possible and i would like the JButton Exit allow me to exit the current Frame.