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
-1
votes
2 answers

Android facebook-sdk crash in Turkish

When I selected Turkish language, I get an error. No problem in other language, if i delete facebook-sdk fix it. But I have to use facebook-sdk.. java.lang.IllegalArgumentException: CLİCK is not a constant in…
-1
votes
2 answers

Parsing DateTime in Java for previous OS versions

I've been practicing on parsing JSON for android apps using The Guardian's API, and I'm having trouble formatting the date into a better looking format. This is what my adapter looks like so far: public class ArticleAdapter extends ArrayAdapter…
-1
votes
2 answers

Trouble throwing IllegalArgumentException in my code

I'm trying to compile a code that's using composition. My goal is to implement data validation code to make sure that when an object is instantiated, the scores that I'm using are greater than zero and less than 300. I've been attempting to throw an…
-1
votes
1 answer

Passing data from one controller to another in javafx. java.lang.IllegalArgumentException

I am creating a reporting application in which I have 3 scenes with 3 controller classes. My aim is to click on a button (Send Email) from my MaintainanceBacklog_Controller Class, which uses 3 ObservableList from the same controller class and 1…
-1
votes
1 answer

IllegalArgumentException with PushServiceApi26.run after upgrading Parse Android SDK

I am getting a recurring crash in the developer console for all the users with an Android >= 8.0 (Oreo). It began to happen after upgrading Parse from 1.15.8 to 1.16.3. Not having much information, I tried to check in the code where the…
Rob
  • 15,732
  • 22
  • 69
  • 107
-1
votes
2 answers

java: illegal start of expression when entering int[]

I cannot figure out what is the error with my input argument, the compiling errors messages are not helping much. import java.util.ArrayList; /** * Created by cheun on 11/8/2017. */ public class Problem2_ProductsOfAllIntsExceptAtIndex { …
dcas
  • 111
  • 1
  • 10
-1
votes
1 answer

Why BeanUtils.copyProperties throw IllegalArgument Exception?

I have two classes with the same attributes and the same get and set methods, one follows the DTO pattern and a VO pattern. So I have something like this: classDTO private String x; private String y; classVO private String x; …
resla95
  • 1,017
  • 2
  • 11
  • 18
-1
votes
1 answer

IllegalArgumentException in ObjectInputStream.readObject

I have an android application which is showing strange behavior. I have a method which deserializes object from file. Below is the code I'm using: public static Object readData(Context context, String fileName) { synchronized (context)…
-1
votes
1 answer

Why is IllegalArgumentException thrown here by Method.Invoke?

For a programming practical task, we are given an example .class file. We need to print out all methods that take 1 x int input and some printable output, and then allow the user to run that method with one input as given through the command line.…
-1
votes
1 answer

Probably a very simply answerable query about throwing an exception

This should be easily and quickly answerable. It is about throwing exceptions, and I have very little understanding of that topic (because I am a novice). The code below represents of the most important methods from my simple 'maze game' program.…
-1
votes
1 answer

How to limit the String arguments that a method can use to a fixed list

The code below is one of the key methods for my simple 'maze game' program (which, despite its simplicity, happens to be my biggest project yet). In this method, I am defining the possible user commands and giving instructions for their execution.…
Noam Hudson
  • 117
  • 9
-1
votes
1 answer

java.lang.IllegalArgumentException, java.lang.NullPointerException, org.json.JSONException in android project

package com.example.attendance; import java.util.ArrayList; import java.util.Calendar; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.app.Activity; import android.content.Context; import…
-1
votes
1 answer

IllegalArgumentException in getPixels() method

I am setting this bitmap on canvas and getting this IllegalArgumentException while using getPixels() method: java.lang.IllegalArgumentException: x + width must be <= bitmap.width() in the line bitmap.getPixels(pixels, 0,bitmap.getWidth(), 1, 1,…
zek54
  • 415
  • 3
  • 20
-1
votes
1 answer

Try / Catch not displaying Exception error message

Hey there so in my class I had written this: public void setId(String id) { ... if (id.matches("[a-zA-Z]{3}-\\d{4}")) { this.id = id; } else { // id is invalid: exception occurs throw new IllegalArgumentException("Inventory…
Seo-Jun Koh
  • 13
  • 1
  • 7
-1
votes
1 answer

IllegalArgumentException thrown when trying to create a BufferedImage

I want to know why I am having this problem when I literally copied and pasted this section of code from one Java project to another, and didn't run into any issues in the first project. I am attempting to display a 4x4 grid of squares. The…
lb91
  • 109
  • 9