• Register

Recent questions tagged array

0 votes
1 answer 2 views
Problem: I want to learn how to break(or split) a String into characters. The end result can be an array of characters or an array of Strings which contain characters?A String is a sequence of characters. But unlike C++, Strings in Java are not mutable. Which means that Strings cannot be changed or modified?
asked 5 hours ago Ali 4.3k points
0 votes
1 answer 4 views
Problem: .. ... int a = scanner.nextInt(); scanner.nextLine(); // Simply consumes the bothersome \n String s = scanner.nextLine(); I know how to read a file with Java using Scanner and File IOException, but the only thing I don't know is how to store the text in the files as an array.
asked 12 hours ago Ali 4.3k points
0 votes
1 answer 1 view
Problem: I am trying to write a very basic nearest neighbor calculation. I basically want to see what t looks like but I got this type error. When I asked the funciton to return just t it said "". When I asked it to turn to list it threw "TypeError: iteration over a 0-d array Python " How do I fix this please?
asked 1 day ago Mashhoodch 9.1k points
0 votes
1 answer 2 views
Problem: When I'm creating an array of objects, how can I add the argument for the constructor inside each object? Like this: foos = new Foo[10]; How do I make 10 objects with their constructors? I do not understand where do I put the arguments that is passed to the constructors of every object?
asked 2 days ago Ali 4.3k points
0 votes
1 answer 3 views
Problem: how to split string by into array by comma
asked 2 days ago kaash_kashi 1.2k points
0 votes
1 answer 4 views
Problem: how can I check if this two dimentinal array is empty? this is my code : String[][] user = new String[5][3]; System.out.print(user.length); if (user.length == 5 ){ System.out.print("\n empty"); } for (int j=0; j<3; j++) { System.out.print(" " + user[0][j]+ "\n"); }
asked 2 days ago Ali 4.3k points
0 votes
1 answer 5 views
asked 6 days ago Akhil k 1.1k points
0 votes
1 answer 9 views
Problem: Is there an easy way to remove an element from a php array, which foreach ($array)does not include that element? I thought setting to null would do, but apparently not.
asked Feb 15 sasha 8.4k points
0 votes
1 answer 13 views
Problem: How to C++pass array by reference?
asked Feb 14 jasimchaudary 640 points
0 votes
1 answer 14 views
Problem: Why Iso c++ forbids variable length array?
asked Feb 14 jasimchaudary 640 points
0 votes
1 answer 11 views
Problem: I want to create a list of options for testing purposes. First of all, I did this: ArrayList<String> places = new ArrayList<String>(); places.add("Buenos Aires"); places.add("Córdoba"); places.add("La Plata"); Then I have refactored the code as follows: ArrayList ... > places = new ArrayList<String>( Arrays.asList("Buenos Aires", "Córdoba", "La Plata")); Is there a better way to do this?
asked Feb 14 sasha 8.4k points
0 votes
1 answer 13 views
Problem: Array of Objects in C++
asked Feb 13 jasimchaudary 640 points
0 votes
1 answer 14 views
Problem: How can I declare an array in Java?
asked Feb 12 sasha 8.4k points
0 votes
1 answer 10 views
problem;What is the easiest way to check if it's empty?
asked Feb 9 kaash_kashi 1.2k points
0 votes
1 answer 12 views
problem;I get a strange error using json_decode(). It decode correctly the data (I saw it using print_r), but when I try to access to info inside the array I get: Fatal error: Cannot use object of type stdClass as array in C:\Users\Dail\software\abs.php on line 108
asked Feb 9 kaash_kashi 1.2k points
0 votes
1 answer 12 views
problem; i got this warning ! Warning: Cannot use a scalar value as an array in line X, Y, Z (the line with: $final[$id][0] = 3, and the next 2). using this code $final = array(); foreach ($words as $word) { $query = "SELECT Something"; $result = $this->_db->fetchAll($query, "%". ... else { $final[$id][0] = 3; $final[$id]['link'] = "/".$row['permalink']; $final[$id]['title'] = $row['title']; } } }
asked Feb 9 kaash_kashi 1.2k points
0 votes
1 answer 9 views
Problem: I am using the armadillo library to perform calculations with matrices, vectors, and other herbs . To speed up compile times, I'm trying to compile the instantiations into a single file, and declare all the templates as externthe files .cppthey are used in: / ... Is there a difference between explicit instantiation and on-the-fly instantiation ? What am I doing wrong ? How do I solve it ?
asked Feb 7 sasha 8.4k points
0 votes
1 answer 8 views
Problem: In one task I am required to implement a function of the form B** f(string, int&);(unmodifiable prototype) where the return value (as I understand it) is a pointer to an array of type pointersB . The case is that I want to generate, from a static arrangement of elements of a type A, a static ... *b; string s=""; int n=1; a.set('A'); b=x.f(s,n); cout<<b[0]->get()<<endl; return 0; }
asked Feb 7 sasha 8.4k points
0 votes
1 answer 6 views
Problem: Hi, I have the problem that I want the classes '' Good Fighter '' '' Bad Fighter '' to access their '' Ki '' attribute in order to modify it. Both classes are modulated in .hpp files. I already tried doing friendly classes but then only one can take life and the other does not, I ... 1 + rand ()% 13; posx = x; posy = y; } int getposx () { return posx; } int getposy () { return posy; } };
asked Feb 7 sasha 8.4k points
0 votes
1 answer 17 views
Problem: This is the instruction in one of the exercises in our Java class. Before anything else, I would like to say that I 'do my homework' and I'm not just being lazy asking someone on Stack Overflow to answer this for me. This specific item has been my problem out of all the other exercises because I've been struggling to find the 'perfect algorithm' for this.
asked Feb 3 Ali 4.3k points