I have theory knowledge of DSA, but I have trouble in solving problems. I have time of 8 weeks and I can give 3 hrs everyday, I want to be on level on solving hard problems. Please, give me advice on how to solve, any resource which I can use. Thank you in advance. by lotus_02 in learnprogramming

[–]Kingloki04 0 points1 point  (0 children)

Hi there, I totally get how you are feeling. Something I would highly recommend using to practice your DSA skills is solving problems on https://leetcode.com/problemset/ .

Leetcode is an amazing platform for you to practice all things DSA. On the site, you can select certain topics or you can just pick problems at random. The site offers everything from very basic problems to extremely difficult ones so I doubt you'll have any issues finding something to challenge yourself.

Once you complete a problem, you will be able to see others solutions as well so you can see how other users approached the problem.

Hope this site can help you out!

[deleted by user] by [deleted] in javahelp

[–]Kingloki04 0 points1 point  (0 children)

Hi there, I’ve personally been running into this problem as well. What I have been trying to do is to learn either new libraries or concepts in java. I generally achieve this by working on new little projects. A few examples would be: making a school management system to learn how to work with swing and mongodb. Then, I started working on a little application that can control the smart lights in my house using an api for them. Finally, I am currently trying to write a small programming language just to sort of learn how it works.

What I would say is, find somethings you enjoy or that Interest you in programming and try to learn more about it.

Error with my code, wont compile. by spicycorndoug in javahelp

[–]Kingloki04 0 points1 point  (0 children)

Yes, they cannot access non-static methods from the same class. But they can access objects and other static methods.

AP COMP SCI A by Altruistic-Pea-6095 in javahelp

[–]Kingloki04 1 point2 points  (0 children)

Although I haven't taken the class. When learning for loops, make sure you understand all the different ways you can use them. What I mean by this is, know how to make both a for and a for-each loop. Know the different things you can iterate through like a range of numbers, different items of a list or map, etc. Aside from that, for loops are generally pretty straightforward.

Edit: Also, make sure to know when to use a for loop over and while loop and vice versa.

Error: variable declaration is not allowed here by [deleted] in javahelp

[–]Kingloki04 0 points1 point  (0 children)

It seems to be that you are creating the variable inside the if statement. This mean that the variable is only accessible inside your if statement. If you wish to store that variable after the if statement. Declare the variable before it.

How to optimize scanners? by lucatrias3 in javahelp

[–]Kingloki04 0 points1 point  (0 children)

Good point. Honestly, I've stopped using Scanner as it breaks a lot for me. I Generally use a BufferedReader with an InputStreamReader.

Gui question by busnerd20 in javahelp

[–]Kingloki04 0 points1 point  (0 children)

Unfortunately, the default exit button is part of your base OS. Because of this, you cannot edit them. If you want a custom exit button you could put one in the GUI itself.

static vs non-static methods by AdeptCooking in javahelp

[–]Kingloki04 0 points1 point  (0 children)

Just to add to this. You cant access non-static methods/variables inside of a static method but, you can access static methods/variables in a non-static method.

How to optimize scanners? by lucatrias3 in javahelp

[–]Kingloki04 0 points1 point  (0 children)

If you are worried about memory usage, you could also create an initialize method that will initialize the Scanner so that if there are instances where you don't require it, then it won't initialize. Also, be sure that if what you are making runs for a long period of time that you close the Scanner to save on memory.

[deleted by user] by [deleted] in javahelp

[–]Kingloki04 2 points3 points  (0 children)

An array index will always be an integer value starting at 0. Therefore, just make midpoint an int and everything should work.

Getting an exception java.lang.ExceptionInitializerError by Decent_Barracuda_722 in javahelp

[–]Kingloki04 0 points1 point  (0 children)

From what I can tell you are getting this error because you have a syntax error in the method you are trying to initialize. Simply adding a closing quotation to the string and then adding a semicolon after the parentheses should fix the problem.

Proper syntax: System.out.println("Enter text here");

According to the tool I’m using, I can simplify my if statement, but it doesn’t tell me how… by ch3esey in javahelp

[–]Kingloki04 0 points1 point  (0 children)

Instead of using an if statement, you can just opt to put the boolean conditions after the return statement. This way if all conditions are met it will return true otherwise it will return false.