Questions tagged as 'java'

1
answer

Return from catch clean code

I'm reading the Clean Code book from the Robert C. Martin series. And a very common situation was presented in my daily life. public static void main(String[] args) { String nome = null; try { if (nome.length() > 10) {...
asked by 12.09.2017 / 14:34
2
answers

Separate sentences into a String

I have this String with a space between the title (upper case) and the description:    RETURNED CARS FOR DISTRIBUTOR   Download again The code: final String linha = row.getCell(3).getTextContent().replaceAll("\t","").replaceAll("\n",""...
asked by 06.09.2017 / 15:56
3
answers

How to get a part of a String?

I need to get only the [nItem:2] of the Phrase: Nota fiscal - 502: Status do retorno da transmissão: 778 - Informado NCM inexistente [nItem:2] Would anyone have any ideas? Remembering that it only matters the excerpt [nItem: XXX]...
asked by 25.07.2018 / 15:06
1
answer

I'm having a problem reading a string variable in java

I created a variable of type string and it is not reading a sentence with a line break, it is simply jumping, in java is there a way to clear buff like C or something that can do? code snippet: Scanner sc = new Scanner(System.in); String nom...
asked by 14.06.2018 / 14:08
1
answer

Error instantiating in Java

In my course on Java OO, I've assembled a class to perform certain functions. But they always return NullPointException. If I do the same thing within the main method, without creating any class, everything works fine. What am I doing...
asked by 08.06.2018 / 16:13
1
answer

Problem with menu switch case and while

My goal is that after I run one of the menu options and say that I do not want to continue on it, I can insert another option (or the same if you want to go back). My code executes the first option that I type but does not pick up the second,...
asked by 30.06.2017 / 06:26
4
answers

Comparing Strings using ArrayList [closed]

I need to repeat the same string, I know that I need to use .equals (), but it is giving error, as if the variable x was checking more value than exists in the ArrayList, but has as condition that x is smaller that the "data.size ()" (which is t...
asked by 29.08.2017 / 18:29
1
answer

Java is not splitting a String correctly [duplicate]

I am trying to split a String using the following character "|" But java is understood to be to divide letter by letter. List<Curso> cursos = new ArrayList<Curso>(); List<String> pacotes = Arrays.asList("Cri...
asked by 07.08.2017 / 21:06
2
answers

EditText without Focus by Activity

Is there a command in Activity that prevents a EditText from receiving focus, even with the user clicking? Or can this only be done by XML? I have a repository that is connected to a database and I need this repository to be pop...
asked by 03.08.2016 / 13:48
2
answers

Memory consumption in java

Good morning, people. I made an application in java that at certain times it executes a query to the database and generates a text file. The application is working correctly in the schedules that have been programmed, however in the time t...
asked by 03.08.2016 / 17:08