[Solved] Generating different object name with for loop [closed]

I believe that what you want to do is this: public String[] getID(){ // Create an array of String of length staffNum String[] tempArray = new String[staffNum]; for(int x = 0; x < staffNum; x++){ // Affect the value Att[x] to each element of my array tempArray[x] = String.format(“Att[%d]”, x); } return tempArray; } 0 … Read more

[Solved] User-enter values are not being stored properly

while ( choice != -1 ) { System.out.println( “Enter a homework grade. Press -1 when finished” ); homework = dylan.nextInt(); } This loop will never exit, because the user’s entry is put into homework, but you’re testing choice in the while loop. The fix: while ( homework != -1 ) { System.out.println( “Enter a homework … Read more

[Solved] Use a 2-D matrix to represent data [closed]

I think this code will work: String arr[][]=new String[4][4]; //For reading name of Cold Drink System.out.println(“ENTER NAME OF COLD DRINKS”); for(int r=1;r<4;r++) arr[r][0]=sc.nextLine(); //For reading name of Cities System.out.println(“ENTER NAME OF CITIES”); for(int c=1;c<4;c++) arr[0][c]=sc.nextLine(); //For reading sales value for(int r=1;r<4;r++) { for(int c=1;c<4;c++) { System.out.println(“ENTER SALES VALUE OF ” + arr[r][0] + ” IN … Read more

[Solved] java Dangling meta character ‘+’ [closed]

You error has nothing to do with the shown regex. The problem is because you use the matched result values as a parameter to replaceAll(), and those parameters are also regular expressions. Since you don’t want them to be interpreted as regex, you need to escape them, or rather “quote” them, like this: str = … Read more

[Solved] How do I correctly implement this code segment without getting a logic error? [closed]

Shoe roshe = new Nike(“roshe”, 11, “black”, “fashion”, 129.0, false) String literals should be enclosed in double quotes. As for your change in size type, pass int array instead of int int s[] = {11,12,13}; Shoe roshe = new Nike(“roshe”, s, “black”, “fashion”, 129.0, false) or Shoe roshe = new Nike(“roshe”,new int[]{11, 12, 13} , … Read more

[Solved] android splash screen timer plugin

I Fixed it my self this this code here: public class SplashScreen extends Activity { // Splash screen timer private static int SPLASH_TIME_OUT = 3000; private SessionManager session; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Session manager session = new SessionManager(getApplicationContext()); // Check if user is already logged in or not if (session.isLoggedIn()) { … Read more

[Solved] Validity check method not working

The condition in both the for loops are wrong, it must be for(int j = 0; j < 9; j++) for(int i=0; i < 9; i++) if (array2[j][i] != array[j][i]&& array2[j][i] == 0) return false; return true; solved Validity check method not working

[Solved] args[0]==null Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 1 at Main.main(Main.java:69)

Without knowing the details of your code, I would suggest you to check the size of args first: if(args.length> 0) { //It depends on the size of the argument you wanna check. //Might be args.length > 1 if you wanna make sure at least 2 elements in the args array //doSomething } else { //doSomethingElse … Read more