In this article I want to tell you about the experience of developing one unpretentious game for Android, which has repeatedly paid off at the development stage!
PrehistoryWe started developing the game in the 10th grade. Before that, we had no experience in developing and promoting mobile games. There were only basic knowledge of Java and a little experience of creating websites. And that's all!
In modern software very often there is a need to perform various operations with all kinds of money. However, until now, I have never found documentation, which would have brought together the basic rules for presenting amounts and implementing financial calculations. In this article, I will try to formulate those rules that have been compiled on the basis of personal experience.
How does the JVM create new objects? What exactly happens when you write a new Object ()?
At conferences, it is periodically told that the allocation of objects uses the thread-local allocation buffer (TLABs): memory areas allocated exclusively to each thread, creating objects in which is very fast due to the lack of synchronization.
But how correctly to choose the size of TLAB'a? What to do if you need to allocate 10% of the size of TLAB'a, but only 9% is free? Can an object be allocated outside TLAB? When (if) is the allocated memory set to zero?
Having asked these questions and did not find all the answers, I decided to write an article to correct the situation.
Before reading it, it's useful to remember how some garbage collector works
Technology: Querydsl is a java based framework which enables the construction of statically typed SQL-like queries. Instead of writing queries as inline strings or externalizing them into XML files they can be constructed via a fluent API like Querydsl.we can use Querydsl in java application for creating all kinds of sql statements.Querydsl has various plugins for JPA,mongoDb, SQL,lucene and also for java collections.
Do you know how much memory the string has? I have heard all kinds of answers to this question, ranging from "do not know" to "string has 2 bytes". Here are some more questions: How much space does empty string take? How much space does the class object of Integer take? How much space will take your own class object with three Integer fields? It is funny, but none of my Java programmer friends could answer these questions ... Most of us do not need it, and nobody will think about it in the real java projects. After all, this is the same as you would not know the engine capacity of vehicle that you drive every day. You can be a great driver and did not even know what 2.4 or 1.6 means on your car. But I am sure that there are few people who are not familiar with the meaning of these numbers. So why do java programmers know so little about this part of their tool?
Integer vs int
We all know that in java - everything is an object. Except, perhaps, primitives and references to the objects themselves. Let us consider two typical situations:
This article explains how to implement some data structures in Java. It will be useful for beginners that use a programming language Java, as well as those who already know how to write a new ArrayList (), but have little knowledge what is happening inside.
Let us talk about the ArrayLists
ArrayList implements the List interface. As we know, Java arrays have a fixed length, and after the array is created, it cannot increase or decrease. ArrayList can change its size at runtime, but it does not necessarily indicate the size when an object is created. The elements of ArrayList can be any types, including null.