Objective-C NSError and Java Error

I need a little information about NSError in Obj-C and if there is an equivalent of it in Java.I found this class : Java Error, but I’m not really sure it it’s the same.Can I use it like in Obj-C as a method params for example :

Obj-C : - (BOOL)synchronizeInternal:(NSError **)error

Java : public boolean synchronizeInternal(Error err)

Any suggestions?


It’s not the same thing at all. The Java Error class is a throwable (i.e. like an exception) but is reserved for serious errors that indicate a problem with the code of the JVM.

I think you would have to create your own class if you want something exactly like NSError. NSError is simply a container that contains some information about a normal error condition e.g. you can’t read the file the user has asked you to open. The kind of thing NSError does is probably better done with checked exceptions in Java.

Leave a Reply

Your email address will not be published. Required fields are marked *