Skip to main content

New answers tagged

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.
Abra's user avatar
  • 21k
Best practices
0 votes
0 replies
0 views

IS there better way to do this?

chars are effectively deprecated. Iterate over code points instead.
Anonymous's user avatar
  • 87.7k
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 ...
g00se's user avatar
  • 4,254
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 ...
Stultuske's user avatar
  • 9,469
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, ...
Marce Puente's user avatar
  • 1,200
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
g00se's user avatar
  • 4,254
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 ...
Dave Newton's user avatar
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 ...
David Maze's user avatar
  • 166k
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 ...
Basil Bourque's user avatar
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 ...
Basil Bourque's user avatar
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 ...
user9712582's user avatar
  • 1,928
-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 ...
Zoom's user avatar
  • 1

Top 50 recent answers are included