[Solved] Boards equals 0 [closed]

int[] numbers = new int[5]; .. System.out.println(numbers[0]); That would print 0 as well. An array of integers without setting a value will have 0 by default. If you receive x = 480, y = 360, num2 = 2 (we don’t know num1), lets assume num1=1 X[num1-1] = x; Y[num1-1] = y; this would be X[1-1] … Read more

[Solved] Java program which sums numbers from 1 to 100

nmb++ is equal to nmb = nmb + 1. It only adds one till it’s 101, which is when it stops. You should add a new variable, let’s call it total, and sum nmb to it every iteration. public class T35{ public static void main(String[] args) { int nmb; int total = 0; for(nmb= 1; … Read more

[Solved] Java 8 — Lambda Expression [closed]

If you want to create a function which adds 1 to its input, the method to create that function doesn’t need an parameters… but then you need to call that function in order to execute it. I suspect you wanted: import java.util.function.Function; public class LambdaExpression { public static Function<Integer, Integer> create() { Function<Integer, Integer> f … Read more

[Solved] Why isn’t this JSP – Servlet code work?

A NullPointerException, most of the time, means that you’re dereferencing a null variable. I assume the line causing the exception (line 97 in z.java, as the stack trace indicates) is the following line: yy.getXs().add(s); Then it can mean two things: yy is null The list returned by yy.getXs() is null. Use a debugger to identify … Read more

[Solved] Why when I uncommenting toString it writes null?

The reason is name and id are null. When you retrieve this.id, it returns the value of this classes (ProductEntry) member variable rather than its super class (which is what you want in this case). If these member variables weren’t defined in ProductEntry, a call to this.id would retrieve the id from the super class, … Read more

[Solved] can someone please point me in the right direction

You don’t store the input numbers, if you only want to print them in the end it is sufficient to store them in a string numbers += ” ” + Integer.toString(number);. The whole main would then look something like that: public static void main(String[] args) { int mstop; int number; int sum; int mcounter; String … Read more

[Solved] Jfreechart add months instead of numbers

Please have a look at the org.jfree.demo.TimeSeriesChartDemo1 class that is included in the JFreeChart download. The source code is included in the source download of JFreeChart, so it’s a good point to start with. I think that’s what you want. Update (revised on your comment): You can change the format of axis labels by redefining … Read more

[Solved] What does this expression evaluate to? [closed]

In Java, the test if (i==f && i.equals(f)) is nonsensical. Since i is an Integer and f is a Float, they will never be == (and, since they are incommensurate types, cannot legally be compared with ==). For reference types, the == operator evaluates to true only if the variables reference the same object, which … Read more

[Solved] What are the foundations to learn before learning path-finding algorithm like BFS, DFS etc? [closed]

I strongly recommend you watch freeCodeCamp – Graph Theory video, as a Computer Science student that video had a lot of information that were hard to get/understand in my college course, even though BFS and DFS aren’t that hard yet still important to know them along with other Graph Algorithms solved What are the foundations … Read more

[Solved] How to get file size in KB and MB in android [duplicate]

Here it’s: public String size(int size){ String hrSize = “”; double m = size/1024.0; DecimalFormat dec = new DecimalFormat(“0.00″); if (m > 1) { hrSize = dec.format(m).concat(” MB”); } else { hrSize = dec.format(size).concat(” KB”); } return hrSize; } SOURCE: Converting KB to MB, GB, TB dynamically 1 solved How to get file size in … Read more