Tag: c

56 votes
3 answers
1.8K views
Why is printing "B" dramatically slower than printing "#"?

I generated two matrices of 1000 x 1000: First Matrix: O and #. Second Matrix: O and B. Using the following

avatar
Shantay
0 1 0 9
asked 07 September, 2021
63 votes
30 answers
2.2K views
Initialization of an ArrayList in one line

I wanted to create a list of options for testing purposes. At first, I did this: ArrayList<String> plac

avatar
Dorian
0 1 0 9
asked 07 September, 2021
52 votes
30 answers
2.6K views
How do I convert a String to an int in Java?

How can I convert a String to an int in Java? My String contains only numbers, and I want to return the numbe

avatar
Louetta
0 1 0 9
asked 07 September, 2021
54 votes
30 answers
924 views
When to use LinkedList over ArrayList in Java?

I've always been one to simply use: List<String> names = new ArrayList<>(); I use the inte

avatar
Sena
0 1 0 9
asked 07 September, 2021
57 votes
29 answers
2K views
What is the difference between public, protected, package-private and private in Java?

In Java, are there clear rules on when to use each of access modifiers, namely the default (package private),

avatar
Lynette
0 1 0 9
asked 07 September, 2021
67 votes
30 answers
834 views
How do I efficiently iterate over each entry in a Java Map?

If I have an object implementing the Map interface in Java and I wish to iterate over every pair contained wit

avatar
Daniel
0 1 0 9
asked 07 September, 2021
60 votes
18 answers
443 views
Why is char[] preferred over String for passwords?

In Swing, the password field has a getPassword() (returns char[]) method instead of the usual getText() (retur

avatar
Chelsea
0 1 0 9
asked 07 September, 2021
64 votes
11 answers
982 views
Why don&apos;t Java&apos;s +=, -=, *=, /= compound assignment operators require casting?

Until today, I thought that for example: i += j; Was just a shortcut for: i = i + j; But if we try this:

avatar
Jeff
0 1 0 9
asked 07 September, 2021
60 votes
30 answers
343 views
Create ArrayList from array

I have an array that is initialized like: Element[] array = {new Element(1), new Element(2), new Element(3)};

avatar
Margo
0 1 0 9
asked 07 September, 2021
60 votes
30 answers
2.4K views
What are the differences between a HashMap and a Hashtable in Java?

What are the differences between a HashMap and a Hashtable in Java? Which is more efficient for non-threaded

avatar
Eddie
0 1 0 9
asked 07 September, 2021
50 votes
30 answers
2.6K views
Avoiding NullPointerException in Java

I use object != null a lot to avoid NullPointerException. What is an alternative to: if (someobject != null) {

avatar
Serina
0 1 0 9
asked 07 September, 2021
52 votes
30 answers
2.2K views
Is Java "pass-by-reference" or "pass-by-value"?

I always thought Java uses pass-by-reference. However, I've seen a blog post that claims that Java uses p

avatar
Emilia
0 1 0 9
asked 07 September, 2021
63 votes
27 answers
2.9K views
Why is processing a sorted array faster than processing an unsorted array?

Here is a piece of C++ code that shows some very peculiar behavior. For some strange reason, sorting the data

avatar
Boyd
0 1 0 9
asked 07 September, 2021
69 votes
3 answers
3.1K views
58 votes
7 answers
1.7K views
CodeIgniter Active Record not equal

In CodeIgniter using active record, how do I perform a not equal to in $this->db->where(). For instance

avatar
Gigi
0 1 0 9
asked 07 September, 2021
62 votes
7 answers
2.3K views
get_instance() in Codeigniter: Why assign it to a variable?

In Codeigniter, get_instance() is a globally available function that returns the Controller super-object which

avatar
Winford
0 1 0 9
asked 07 September, 2021
60 votes
3 answers
458 views
Disable PHPStorm new file branding

When I create a new file using PhpStorm it creates it's own comment at the top, this would be fine howeve

avatar
Juliane
0 1 0 9
asked 07 September, 2021
58 votes
7 answers
2.3K views
Codeigniter - multiple database connections

I have to retrieve a MySQL database information from master database and then connect to that database, and fe

avatar
Louetta
0 1 0 9
asked 07 September, 2021
59 votes
2 answers
1.9K views
How do I use PHPUnit with CodeIgniter?

I have read and read articles on PHPUnit, SimpleTest, and other Unit Testing frameworks. They all sound so gre

avatar
Venice
0 1 0 9
asked 07 September, 2021
61 votes
9 answers
786 views
Directory index forbidden by Options directive

I'm using the dompdf plugin for codeigniter: http://codeigniter.com/wiki/PDF_generation_using_dompdf/ to

avatar
Arline
0 1 0 9
asked 07 September, 2021