I was studying about bluetooth and I was trying to write the code to keep listening to the input stream while connected and i came across this following code snippet: Can someone explain what is the difference between 0x0A and 0x0D. And also give a brief explanation about this code. Kindly share your views. A…
Tag: java
Is this a stack?
Is this code a stack? How I can make it better? This is my first one. Can i do this using ArrayList? I didn’t added the isEmpty() method. Answer Yes, it is. But you can add checking for overflow, underflow. And this will be better if you’ll try using collections.
Displaying some query records in random order (Parse.com)
Okay so the following is my ParseQuery. How can I display most but not all of the records in random order using Collections.shuffle() in this context? For example, I have a specific record that I want …
query.orderByRandom with Parse.com? – Displaying records in random order
I understand that you can do the following… But what if you actually want your data to come out in random order every time your activity is opened? How might this be accomplished? Answer There is no built in function for random sort order in the Parse API. You can randomize the list after you receive it…
Print a Z shape pyramid using * stars
I am trying to write a program that outputs a Z pattern that is n number of * across the top, bottom, and connecting line using for loops. Example: This is my current code, it’s producing a half pyramid upside down. Answer This is the logic in the following code: Loop over each row of the output (so fro…
How do I use SQLite in android?
I’ve founde already a few answers to this topic (for example this), but it is not working. I only get the warning, that it cannot resolve the method ‘openOrCreateDatabase(java.lang.String, int, null)’. Here is my sourcecode: Answer SQLite is a opensource SQL database that stores data to a te…
File is corrupted after creating excel (.xlsx) file by using Apache POI with Java
I have created a Workbook/Excel in .xlsx format with Java using Apache POI API successfully. My code is as below that is created a file named “RiponAlWasim.xlsx” in D drive: When I tried to open “RiponAlWasim.xlsx” it was shown the file is corrupted. What’s the wrong? Answer It n…
ObjectInputStream readObject in while Loop
Is it possible to read from ObjectInputStream in while loop which will terminate by exception thrown by socket timeout socket.setSoTimeout(4000); Answer When you say ‘not working’, what you really mean is ‘not compiling’, for reasons that are stated in the compiler message: Object isn&…
Why Getting NoClassDefFound error for JedisConnection when using Spring Redis
Hello when trying to use spring-redis i am getting exception when doing any connection operation using redis. My config method goes like this Please suggest if anyone knows why i am getting this exception. Answer After wasting almost one day and finding that the jar is already on my class path, i further debu…
spring boot starter security post methods not working
I have added spring ‘spring-boot-starter-security’ to existing spring boot project ; after that the post methods in spring rest controller not working properly it shows a error something like this : my controller method is this: pom file: if i remove all these security related stuff the code is wo…