java-faq

What is stack trace, and how to use it to find errors in application development?

Sometimes when I run my app I get a similar error: Exception in thread "main" java.lang.NullPointerException at com.e ... cing. Translation of the question: "What is a stack trace, and how can I use it to debug my application errors?" @Rob Hruska

Java books and learning resources

The answers to this question were written by the joint efforts of the community. To improve this message, edit the existing r ... he general answer. This list is included in the community-supported Collection of educational resources on programming.

How and how to parse Json in Java?

There is often a need to work with Json, in particular its reading and parsing. In Java, you usually know what type of variab ... "type": "home", "number": "999 111-1234" } ] } ] }

How to compare strings in Java?

In my program, I used the == operator to compare strings. But I came across a bug, and when replacing == with equals, it disappeared. Should the == operator be avoided? When can it be used and when not? What's the difference?

What is null?

null is it an instance of something? What type does null belong to? What is null? How is it represented in memory? Free translation of the question "What is null in Java?" from the participant @unj2.

How to write micro-tests in Java correctly?

What is the best way to write micro-tests/performance tests in Java? What are the main points to pay attention to?

How does the foreach loop work in Java?

There is a collection and a loop foreach: List<String> someList = new ArrayList<String>(); //add "monkey", "donk ... reach loop above look like? How does the foreach loop work inside? What is the difference between the for and foreach cycles?

What is the difference between the map and flatMap methods in Java 8?

What is the difference between the methods Stream.map and Stream.flatMap apart from each other?

What is the difference between sleep and wait?

What is the difference between TimeUnit.SECONDS.sleep(1); and this.wait(1000)?

Lambdas in Java 8, which is better to use - Function.identity () or t - >t?

Question about using the Function.identity() method. Let's say there is the following code: Arrays.asList("a", "b", "c") ... he new person does not know what identity is doing). But is there a "real" reason why one of the methods should be preferred?

A foreach loop versus an Iterable loop.foreach in Java 8: what's better?

Which of the following is the best practice in Java 8? Java 8: list.forEach(e -> e.operation); Java 7: for (E e : lis ... bdas, but are there any real benefits from using Iterator.foreach? Will the performance and readability of the code improve?

What are the differences between findFirst and findAny in Java 8?

I don't really understand the difference between findFirst() and findAny() in the Java Stream API. I thought that findFirst ... and Stream.of(...).findAny() Then they both return the first element of the stream. Why? Are they both doing the same task?