Questions tagged [illegalargumentexception]

An exception that indicates that the arguments supplied to a method or function are not valid for their intended purpose, or are different to the format expected by the method.

An exception that indicates that the arguments supplied to a method or function are not valid for their intended purpose, or are different to the format expected by the method.

This could occur as a result of many different actions, such as...

  1. You are calling a method that accepts a low-level object type for an argument (such as Object) but you're passing an object that is not one of the types expected by the method. For example, the method might be declaring the argument as an Object so that it can capture a range of different objects in the one method, but the code implementation of the method only allows objects of certain types (such as expecting a Number-based object, and you're passing a String).
  2. You're using methods that are building a dynamic structure for use in a different context, and the argument that you're passing is not valid for the other context. For example, you might be building an SQL statement, and you're passing an argument as a String for a database field that expects a Number. The database context would detect the error and report back the exception.

This type of exception may be hard to predict, as it won't be detected at compile-time, and may only show up under certain circumstances.

965 questions
-3
votes
1 answer

java.lang.IllegalArgumentException for specific URL

I am getting this error when calling API, but this error is not coming to the app the API URLs. java.lang.IllegalArgumentException: Illegal character in scheme specific part at index 6: https:
user3876059
  • 90
  • 1
  • 7
-3
votes
1 answer

joshdholtz CropImageView createbitmap java.lang.IllegalArgumentException: x + width must be <= bitmap.width()

For cropping images I am using CropImageView of joshholtz (https://github.com/joshdholtz/CropImageView). But I am getting IllegalArgumentException exception (saying: x + width must be <= bitmap.width()) at CreateBitmap function at crop function in…
-5
votes
2 answers

Try...catch statements exercise in Java

Java newbie here and I'm doing an exercise trying to catch thrown exceptions by using as few try...catch statements as possible. When I compiled the code, I received IllegalArgumentException errors and wasn't sure how to fix this by using the…
MJW
  • 41
  • 1
  • 1
  • 4
-5
votes
3 answers

Throwing exceptions syntax java

I'm having a hard time figuring out how to throw and catch exceptions. I Think I have the general syntax right, at least according to the book that I'm using, but I keep getting errors. Can anyone help me out with the syntax? public Movie( String…
user3420212
-7
votes
1 answer

IllegalArgumentException: width should be > 0?

I use Asynctask to set the image to RecyclerView when the page is executed Asynctask takes a recyclerView's width and height However, this error occurs 'IllegalArgumentException: width should be > 0' I looked up similar cases and saw that it was a…
1 2 3
64
65