New answers tagged methods
Best practices
0 votes
0 replies
0 views
IS there better way to do this?
If you are looking to improve your code, perhaps CODE REVIEW is more appropriate.
Best practices
0 votes
0 replies
0 views
IS there better way to do this?
chars are effectively deprecated. Iterate over code points instead.
Best practices
1 vote
0 replies
0 views
IS there better way to do this?
This way, you avoid a lot of processing in case there aren't any. That doesn't make sense really. Let's leave aside the fact that the current spec and implementation indicate that the requirement ...
Best practices
0 votes
0 replies
0 views
IS there better way to do this?
Save a new String, in which you store a reference to: String testCaps = sentence.toLowerCase(); if ( !testCaps.equals(sentence) ) => you know there's at least one upper case. This way, you avoid a ...
Best practices
0 votes
0 replies
0 views
IS there better way to do this?
I see two possibilities: either you convert onlyCaps into a class attribute and getCapitalsOnly() returns a boolean indicating whether capital letters were found, or you return an array of Object, ...
Best practices
0 votes
0 replies
0 views
IS there better way to do this?
Try it with this: getCapitalsOnly("đź…’hallenge" ); How is that defined? Run echo 'Character.isUpperCase("đź…’".codePointAt(0))' | jshell
Best practices
3 votes
0 replies
0 views
IS there better way to do this?
The current code mixes status with results—to quote Brian Fellows, that method is a liar. There are several ways to address that particular nit. Re: exceptions (as suggested) is one of them; I don't ...
Best practices
0 votes
0 replies
0 views
IS there better way to do this?
Please edit your question to have a more descriptive title. It will help if you can also describe what you've done already and clarify what exactly the problem is. The one thing that jumps out at me ...
0 votes
Java Method to find uppercase letters and numbers in a String
tl;dr Use code point integer numbers when working with individual characters. Avoid char type. "Hello 42" .codePoints() // Generate an ` IntStream ` of code points. .filter ...
0 votes
ArrayList error, Exception in thread "main" java.lang.NullPointerException
Initialize your list Perhaps you neglected to establish an empty list to hold your destinations. In this example, we use new ArrayList<>() to establish a new empty list on the same line where we ...
Best practices
0 votes
0 replies
0 views
Using Julia's multiple dispatch as an interface vs as a lookup table for extensible library code
The linked "performance tips section" notes that what is reasonable depends on how it will be used: OK if fm are time consuming so dispatch is a tiny part of the time, or OK if the user type ...
-2 votes
ArrayList error, Exception in thread "main" java.lang.NullPointerException
Array list is part of the java.util package and implements the List interface. The difference between a built-in array and an ArrayList in Java, is that the size of an array cannot be modified (if you ...
Top 50 recent answers are included
Related Tags
methods × 30437java × 11443
class × 4765
c# × 3625
python × 2986
arrays × 2573
javascript × 2365
function × 1672
object × 1637
ruby × 1428
oop × 1252
php × 1239
android × 1121
c++ × 1112
string × 909
objective-c × 809
parameters × 769
ruby-on-rails × 766
variables × 747
return × 639
static × 638
inheritance × 573
constructor × 483
call × 478
arraylist × 472