Skip to content
Advertisement

Tag: exception

How to handle empty scanner input strings in java?

I’m working on a .xml file generator. It works by asking the user to input 5 different values and then using them for generating a .xml data container. This is the code: I want the program to detect when someone inputs an empty string by pressing the enter key with no written text and print a message asking the user

Java. Handle dead code (by application logic) in catch block

I have the following piece of code. Is there a better way to handle the dead catch? The “file” variable is loaded by a resource manager, that already handle the case of a file not found (by throwing an exception itself). This is “dead code” only because of application logic, if it was not for the manager doing the check,

Way to overcome fail-fast iterator in HashMap

In competitive programming, I was solving a given problem – given an array nums of non-negative integers, and a target sum S, we have to find out the number of ways we can obtain target sum from sum of given numbers (where each nums[i] can be taken as nums[i] or -nums[i]. Although I came across some solutions that mainly relied

Problem resolving an android.content.res.Resources error

I understand that this error has been addressed severally and I’ve checked most of them like Android: android.content.res.Resources$NotFoundException: String resource ID #0x5, android.content.res.Resources$NotFoundException: String resource ID to see if I could find a solution to my problem but I couldn’t and most of them are hard to understand. I can’t tell if my code is an int/string so I don’t

Java: Why does my program receive java.io.FileNotFoundException error for creating an input file when it successfully creates an output file?

I created two files in this program: “OutputFile.txt” and “InputFile.txt”. When I run my code, it displays an error called “java.io.FileNotFoundException” but it created “OutputFile.txt” in my system but not “InputFile.txt” Why is that? Answer 2 File objects are created: outFile and inFile, this will create text files in my system The first part of this is correct; the second

Advertisement