Questions tagged as 'java'

2
answers

How to limit characters?

I would like to know how to limit characters and then run something on Android. For example, in a EditText or a TextView I type 5 characters, typing the fifth character executes a command, for example, it deletes what was typed....
asked by 28.01.2015 / 18:16
2
answers

Why does not Java add the numbers into expression? [duplicate]

public class Teste { public static void main(String[] args) { int x = 0; int y = 1; int z = 2; System.out.print(x + y + z); } } This returns: 3 public class Teste { public static void main(String[] a...
asked by 20.04.2018 / 19:20
3
answers

Check if the element exists in the ArrayList and, if not, add it

I created a State class with name, acronym and capital and a Country with name, capital and states - an ArrayList of type State. I want to create a method insertState (State e) that before adding the state into a Country, checks if it has not...
asked by 23.08.2015 / 21:47
2
answers

Which tool to use to generate releases in Java?

I am developing my first project in Java, the application is an API using several libraries, among them: Jetty, Hibernate, HttpClient, JasperReport ... In this project I use the Maven framework, I would like to know which tools to use to gene...
asked by 13.12.2013 / 12:36
2
answers

Many "if" in an old game for android

When checking if someone has won, I need to use IF several times. I would like to know if you can simplify the code a bit and even replace the IF s. //left, top, right, bottom are int positions relative to canvas //state is a enum{Blank,Re...
asked by 06.08.2018 / 22:20
3
answers

Verify that you have more than one character in a String

How can I check how many "@" has in a String? example:    "@ Testing" It has 2 @ , how can I do this check in java?     
asked by 07.03.2017 / 01:29
2
answers

Fill JComboBox with an object

Would you like help filling out a JComboBox with one class. In this class, return two parameters: Id and Desc. Category class I need to show in combo: private int Id_categoria; private String Desc_Categoria; How do I show only...
asked by 28.12.2015 / 02:21
4
answers

What is the function of the "| "Inside the catch?

I read that || (OR) is for boolean operations and | (Bitwise operation) for bit operations. What is its function inside a catch with multiple exceptions , then? I mean, I know it eliminates duplicate code but I've always considere...
asked by 22.04.2015 / 20:15
2
answers

Does passing objects in Java simulate passage by reference?

Everyone says that Java goes by value, including Objects. These are passed by copy and can not be reassigned to a new object within the method. The problem is that it is possible to change the value of objects within the method. Does not this ch...
asked by 21.04.2015 / 15:52
1
answer

How to get the public IP of a user connected via socket?

I need to get the IP address of a user who will connect remotely to my program, and list it, the program itself is a chat where only the server will store the users IP address. The client connects via socket, how to proceed to capture the IP?  ...
asked by 19.11.2014 / 01:00