[Solved] java progaram for permutations of two inputs, one string and one integer [closed]

import java.util.LinkedList; import java.util.List; import java.util.Scanner; public class Permutation { static int c; List<String> permutations = new LinkedList<String>(); Scanner sc=new Scanner(System.in); String input =sc.nextLine(); int conbinationSize = sc.nextInt(); boolean[] isChoosed = new boolean[input.length()]; public void generateCombination(String partialOutput) { if (partialOutput.length() == conbinationSize) { permutations.add(partialOutput); c++; return; } for (int i = 0; i < input.length(); … Read more

[Solved] How do I reverse a number in java

You are mixing types. “025” is not an integer, it’s a String. In integer you simply cannot distinguish between 25, 025, 0025, 00025, … Implement your assignment as a String operation. public String reverseString(String s) { // put your code here } You may find very useful the Oracle tutorial on Strings here: https://docs.oracle.com/javase/tutorial/java/data/strings.html 7 … Read more

[Solved] Java Class wont notice numbers over 9 [closed]

You have defined bott_num as int bott_num = 9; So it will start with 9 but your print: System.out.println(“there’ll be ” + (bott_num – 1) + ” green bottles, hanging on the wall”); prints bott_num – 1 which in your case would be 8. So i would sugges you start with 11 so you will … Read more

[Solved] Switch from one Activity to another one results OOM error on Samsung device

I’ve tried various ways to implement something more creative, such as: BitmapFactory.Options options = new BitmapFactory.Options (); options.inJustDecodeBounds = true; … to make better prevent the outflow of memory but I had no success. In the end I decided to use android:largeHeap = “true” under the tag of my application manifest file, and that solved … Read more

[Solved] Creating object using user input to store in Java array

Create a class student with variables for each of the fields: public class Student { public String strFirstName; public String strLastName; public String strMajor; public int intGPA; public int intUIN; public String strNetID; public String strAge; public String strGender; public static void Student(String strFirstName, String strLastName, String strMajor, int intGPA, int intUIN, String strNetID, String … Read more

[Solved] Servlet context is not working

Answer Hashtable.contains() Tests if some key maps into the specified value in this hashtable. So, within your Servlet at this line if(!playerList.contains(playerid)) { you’re actually comparing a key (playerid) with all the values (Player objects) in your Hashtable. Hence, the match is failing every time. Your ServletContext (as well as its listener) works fine since … Read more

[Solved] What exactly does ‘void’ do?

void is a return type of the method. A void method can modify the value without returning it. float temp ; /*Here you are just setting up the value * the method is not returning anything so * it should be called like this obj.setTemperature(20.0); */ void setTemperature(float newTemp) { temp = newTemp; } /*Here … Read more

[Solved] .jar does not run and cannot find external jar

I don’t think I deserved the downvotes but hey. Well anyway the problem was that I was referencing .jars within .jars, I didn’t think that this would be a problem but it was. The solution was to put the .jars (libraries) alongside my compiled application .jar and update the manifest accordingly. it is also possible … Read more

[Solved] How to use “pauseTimers”

You’re trying to access a non-static method in a static way. Firstly a quick explaination of what a static method does. Consider this class: public class ClassA { public void methodOne() {} public static void methodTwo() {} } methodOne is an Instance method. This can only be called from an instance of ClassA declared with … Read more

[Solved] Violating Single Responsibility Principle and static methods [closed]

A few random thoughts. (a) Can you even pin down precisely what it means for a class to have some “responsibility” ??? And subsequently, if (as I suspect) all you have is vague notions without any formally observable / measurable properties / characteristics to pin down the meaning of “responsibility”, then how can you say … Read more

[Solved] Local Variable Initialization Java [duplicate]

Look at it like this what happens when the if condition in your code is not met? The reason you would be getting an error saying : The local variable var may not have been initialized is because if the condition is false you really don’t have var initialised, do you? On the other hand … Read more