Bart Wtoras

Greenhorn
+ Follow
since Jan 09, 2016
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Bart Wtoras

Currently I'm doing raw JDBC, but in the next module of java dev. course I will have Hibernate.
Anyway thank you guys for your time, now it's crystal clear.
5 years ago
Hi guys, I'm building DAO interface for a few classes. Every single class (users, exercises etc. ) connects with same MySQL database. I'm wondering what else besides CRUD I should implement in the interface. Maybe: Connection, PreparedStatement? Should I code whole CRUD methods in DAO interface, or just simple: void save(T t); void update (T t); etc. , and then override all methods for each classDAO separately?
5 years ago
Yes you are right, it does not return number I'm looking for, now it returns 1. I should have read more carefully.
This is accurate description: It has to check if an array contains a number, and if not throw an exception.
5 years ago
This is a 100% accurate description of the requirements:

version 1 wrote:
Implement given method, so it would return the searchable element from the given array in case it is found, otherwise throw an exception.  

5 years ago
Thank you for pointing out that error, and wasting your time helping me.
Have a good day/night.


5 years ago
What is important in this task is throwing an Exception in case when nothing is found in an array.

I have found a solution, throw new Exception solved my problem. Here's my code slightly modified:



Is there a more solid way to build this method?
5 years ago
Thanks for the reply.


Complete the method signature with information that it can return the Exception.


I assume they want me to use throws Exception for the elementExists method.

version 1 wrote:
Implement given method, so it would return the searchable element from the given array in case it is found, otherwise throw an exception.


Version 1 looks like the function I'm looking for.


Here's my method looking for a number in an elements array . By the first occurrence of the number it breaks the for loop and returns: 1, else it returns: 0. I have no idea how to implement throws Exception when method does not find any matching number.



5 years ago
Hello, this is my task:

Create a method: static int elementExists(int[] elements, int number)
The method has to check if in an array: elements, exists element of the value: number.
If the value does not exist, method will return an exception of the type Exception with a comment: "There is no such element".
Complete the method signature with information that it can return the Exception.

I know how to handle an ArrayIndexOutOfBoundsException when the int number points at index. I also have no problem with building method that will check if an array contains an element. But in this case I'm clueless.

So I'm asking a kind person for help.
Bart


5 years ago
It is working now
Thank You very much.
8 years ago
Hello, I'm an absolute beginner in Java and programing. I've bought Head First Java book 2nd edition to learn something. After JDK installation I've tried to compile the very first code from the book, simple code about party invitation. I open MS Word and write code exactly the same as it is in the book. I rename file from party.docx to party.java. When i go to cmd, and run: javac party.java, cmd shows 100 errors and freezes so I have to shut the proces. I tried also with other codes and results are the same. Sorry for bothering you with such a noobish question and for my English. I run it on Win 7, Java 8, JDK 8 u66.
8 years ago