Questions tagged as 'java'

2
answers

Using the Java Scanner

I was doing an exercise for the university using the class Scanner and something unusual happened, watch the code. for(int i = 0; i < 11; i ++){ //problema(esta pulando a escolha de um dos jogadores, precisamente o jogador 1) Sys...
asked by 28.08.2014 / 13:40
1
answer

How important is it to implement the hashCode method in Java?

How important is it to implement the hashCode method in Java? How does the hashCode method differentiate two objects?
asked by 31.03.2014 / 16:03
1
answer

How to use debug in Eclipse?

I'm having a very annoying problem with a java.lang.NullPointerException error and I want to know if with debug it shows which element is null, rather than just saying what line the error is in.     
asked by 09.02.2014 / 00:10
2
answers

Performance in Java string creation

What is the best way to create Java strings for better performance? Here are two examples of creating strings in Java: Ex. 1: String str = "string"; Ex. 2: String str = new String("string");     
asked by 03.06.2014 / 23:11
2
answers

What is the "Principle of Dependency Inversion" (DIP)?

I am now familiar with the SOLID principle: S Single Responsabilty Principle O Open / Closed L Liskov Substitution Principle I Interface Segregation D Dependency Inversion Principle However, I could not understand the...
asked by 02.12.2015 / 16:58
3
answers

What's the difference between using Object.toString () and String.valueOf ()?

I was doing some tests and realized that using one or the other, the result ends up being the same. I made this code to exemplify: public class ParseToStringTest { public static void main(String[] args) { new ParseToStringTest().p...
asked by 29.05.2017 / 16:49
4
answers

Getters and Setters are obligatory or facilitators?

Lately I have read some Java books, but there is a part that makes me confused in this kind of accessor methods - gettters and setters. The question is: I'm forced to write in this type of methods, for example, getName () or just have to w...
asked by 24.09.2014 / 15:49
3
answers

What is the purpose of the Serializable interface?

Implementation example: public class MyClass implements Serializable{ private static final long serialVersionUID = 1L; }     
asked by 22.09.2015 / 15:50
2
answers

What is the difference between Boolean and Boolean?

I ran some tests using Boolean and boolean and apparently returned the same result. See below: Boolean bool = true; boolean bool2 = true; if(bool) Log.wtf(TAG, "Funciona!"); if(bool2) Log.wtf(TAG, "Funciona também!...
asked by 24.10.2016 / 15:57
2
answers

What is a Thread? How does it work?

I was confused about what a thread is and what it represents. I found the following definition for it:    Thread is a small program that works as a subsystem, being   a way for a process to self-divide into two or more tasks. It's th...
asked by 28.10.2015 / 23:20