[Solved] Java Calculator minus error

Take a look at your btMinusActionPerformed method: private void btMinusActionPerformed(java.awt.event.ActionEvent evt) { // minus button firstNumber = Float.parseFloat(calScreen.getText()); OP = “-“; numberClick += 1; if (!calScreen.getText().equals(“-“) && numberClick == 2){ btEqual.doClick(); } else { calScreen.setText(“-“); // <- What does this do? } } Then take a look at the btEqualActionPerformed method: private void btEqualActionPerformed(java.awt.event.ActionEvent evt) … Read more

[Solved] derived class not needing some of the parent methods or attributes

I’m not quite sure what you are trying to do with this. But I think this will clear up the things for you. public class Course{ private String course = “CS101”; } public class FinishedCourse extends Course{ public void displayCourse(){ System.out.println(super.course); //compilation error. //You cannot access private variables even if it is in direct parent … Read more

[Solved] Analyze the following code, which exception does it display? (Exception handling, java)

The block: catch (Exception ex) { System.out.println(“NumberFormatException”); } will catch all the exceptions, as the Exception class is the base class for all the exceptions. When you catch Exception, you catch all the exceptions that extend Exception, which, all the exceptions do. Hence it produces the error that RuntimeException has already been caught solved Analyze … Read more

[Solved] Renaming button name [closed]

Your question is not very clear, but the String name is a java.awt.Component property. In case you mean this name, you can change a component’s name with .setName() and get the name with .getName(). A component’s name by default is null, until you set it. It makes usually sense to .getName() in listeners. Here is … Read more

[Solved] best Java code to control big heap memeory used (like 1G) [closed]

Quickly allocate 1 GB of memory: byte[][] memoryWaster = new byte[1024][1_048_576]; See last test run below for successful allocation of 16 GB of memory. Test program Runtime runtime = Runtime.getRuntime(); System.out.printf(“total: %11d max: %d%n”, runtime.totalMemory(), runtime.maxMemory()); System.out.printf(“used: %11d%n”, runtime.totalMemory() – runtime.freeMemory()); System.gc(); System.out.printf(“gc: %11d%n”, runtime.totalMemory() – runtime.freeMemory()); byte[][] memoryWaster = new byte[1024][1_048_576]; memoryWaster[0][0] = 2; … Read more

[Solved] Sqlite select value as id to other table

You need to fix your table A so it is in First Normal Form: Name Value a 13889483-d92a-483e-9e16-471cb22b82a3 a a7ced9c5-e7bc-4214-be77-a26d8f86844b Then you can connect the tables using a SQL join: SELECT B.* FROM A JOIN B ON B.Name = A.Value WHERE A.Name=”a” solved Sqlite select value as id to other table

[Solved] How do I do my homework with Arrays, Functions and Binary Search? [closed]

For a start, here is the original ArregloBinario class with the spacing fixed up: package laboratorio9; import java.util.Random; import java.util.Arrays; public class ArregloBinario { private int[] datos; private static Random generador = new Random(); public ArregloBinario (int tamanio) { datos = new int[tamanio]; for (int i=0; i<tamanio; i++) datos[i] = 10 + generador.nextInt(90); Arrays.sort(datos); } … Read more

[Solved] Netbeans desktop application of teacher attendance [closed]

You may want to add a LayoutManager to your window. NetBeans has support for it. Right-click inside your window in NetBeans, hover “Set Layout” and select a proper LayoutManager. I always use GridBagLayout. Here is a tutorial: http://docs.oracle.com/javase/tutorial/uiswing/layout/gridbag.html Good Luck. 10 solved Netbeans desktop application of teacher attendance [closed]

[Solved] How can I do my data consistent in java [closed]

It looks like you’re not trying to make it “unique” but, like the title says “consistent.” This is difficult to do. What you need to do is parse the data, allowing for different types of identifying strings. For example, for house, it looks like you want to accept “Ho. #”, “h no.”, and “h#”. Once … Read more