This problem in general is very complicated, but when we don’t need to be 100% sure (but probability is near 1) about our results there is a very easy way to do this.
We’ll use method isProblablePrime from class BigInteger.
This method as a argument gets probability level, it’s calculated as 1 – 1/(2^x), where x is argument, so for x = 20, we can be nearly fully sure about result, the probability is 0,99999904632568359375. For smaller numbers this method gives even more sure results.
How to use it:
long x = some_value;
BigInteger bi = BigInteger.valueOf(x);
boolean isPrime = bi.isProbablePrime();
Firstly we set x to some value, then a new BigInteger is created based on x value, next we use method to check if it’s prime.
more information about BigInteger you’ll find here: http://java.sun.com/javase/6/docs/api/java/math/BigInteger.html
Hello, this topic is also not very complicated, so the post will be quite short.
We have to remember about some rules before we add icon to a MIDlet:
- Only PNG’s are allowed
- icon’s size is not standarized
- some phones will expand smaller icons, some won’t
- the icons that are to big might be shrinked or cut to smaller, we can’t decide
- I recommend using size 32×32, it is smaller than most phones can hold, so at least we can be sure, that it won’t be cut
- icon files, if we want to reffer to it as: “/icon.png” should be placed in src directory in project’s path I think it’s the best way to do this (this file will be automatically added to newly created JAR file)
- After starting Netbeans we go as before to project’s properties, here we open “Application Descriptor” again, then we select second tab:
- Now, after choosing “Edit…” we can select file:
- Next, we have to add appropriate attribute to our JAD and manifest. Let’s click “Add…”, automatically first to add will be icon attribute:
- At last you can run this MIDlet in the emulator (or upload to your mobile). You should see icon you have selected for your app.