Ahmed Sabrioglu

Greenhorn
+ Follow
since Sep 04, 2019
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
4
Received in last 30 days
0
Total given
5
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ahmed Sabrioglu

it says:



This is the folder structure:

testProject
     |
   mod1
     |_____________________
     |                                     |
   src                             module-info.java
     |
   pkg
     |
 classes
     |
 MyClass.java


MyClass is a simple hello-world program:



and this is the content of module-info.java:


 
Now when I move to folder mod1 and try to compile the module-descriptor by issuing this command:



the following error message is issued:



 

Can anyone help please?
1 year ago
don't bother... found the answer:


A stream is closed when a terminal operation is called. A stream is operated on when you call *any* stream operation.

You bind two operations to the stream you create on line 3: the mapToInt() on line 4 and the mapToDouble() on line 6. That's not allowed.

1 year ago
Hi,

we have this code:



Why is it, that when i activate line

that this exception comes:

Because I thought that streams are only not usable anymore after a terminal operation is called... i commented out the terminal method collect at the bottom...
1 year ago
Hi,

sure, you're welcome and yes... after reading your post ;)

... I'll do that right away.. thanks for the hint...
Hey folks,

I'm in the process of learning / preparing for the 1z0-817 upgrade exam, since I already have the OCP Java SE 6 certification.

And since there is so little material dedicated to this specific exam, I decided to make a video series with all the material needed to pass this exam.

I have already covered the exam topic 'Language enhancements', am almost through with 'Interfaces' and half through with 'Lambda expressions'.

I'm planning to release about 1 new video per week covering one subtopic of one exam topic, so it will take a while until everything is finished.

Nevertheless, you're welcome to peek right in and tell me what you think and also learn some things, if you are also planning to take this exam
(or just want to learn the major new things in Java 7, 8, 9, 10 and 11 ) .
In these cases, it's best if you subscribe to my channel, so you stay updated and get notified about the latest videos.

These are the links to my channel and the playlist with the videos:

Channel: Boras Developer Academy
Playlist: 1z0-817 video series Java SE 11 upgrade exam study guide


I would be happy about some feedback, positive or negative, so I can make the videos better.
The reason why I asked was because I got an assignment and one of the requirements was exactly this...

My initial reaction when I heard this was exactly as your responses... but I wanted to check if there is something out there and I missed it maybe...

allright, I think we can close this thread. Thanks all for the input...
1 year ago
i have an idea...

what do you think of a global, central huge database in which developers can check-in their errors and their solutions.
And the error-handling routine checks this db for solutions and provides some if present.

the npe example was basic... it may be trivial for you but imagine some error that you don't know the solution for and have to google it up of ask some forums for help...

think of it something like stackoverflow but as a webservice or something like that....

would definitely save time researching for the problemsolving....

i can give a good example for this:

I once had to solve a hibernate problem in production. for a specific action (querying the db) the application stalled and the result was a timeout....
researching the internet for the stacktrace didn't yield a solution immediately, only after quite some research i figured out that hibernate has its performance problems in some areas...
and in my case it was a union... and the solution i came up with was to break this union up into 2 select statements and joining them... worked like a charm.

now if we had a tool like this i image it to be really simple, like a key value thing... key is the stacktrace with all the specific stuff omitted and value is the solution... so the original stacktrace would be something like:

Caused by: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:94)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028)
at org.springframework.orm.hibernate3.HibernateTemplate$28.doInHibernate(HibernateTemplate.java:883)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
... 65 more


(this is not the original stacktrace of my problem i described above, cant remember it... this is only figurative...

so the key entry in the db would be something like

Caused by: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update



and the solution entry in the value part would be something like

replace union by 2 different select statements and join them

... and maybe some more explanatory text in some other fields...

this could be realized as an eclipse or an intellij plugin or something like that....

it would also be possible to show multiple possible solutions for a specific problem....





PS:

the automatic solution i meant with prior asking the user for acceptance (yes / no)... so suggesting it first...

and modifying its own sourcecode: i think that its possible to write a program which prints out its own sourcecode...from ken thompsons reflections on trusting trust:

"It is very difficult for a programmer to trust the code written by others. To delineate this, Ken talks about one of the programming exercises he participated in. The goal of the exercise was to create the shortest self-producing program i.e to write a source program that, when compiled and executed, will produce an exact copy of the source as its output."



so make a new file, modify it accodingly and delete the old one... but thats not the important part the important part is the solution-suggesting part....

i know of static code analyzers like sonar for example... but they are restricted to technical problems only... in the real world we have domain-specific problems also... have a tool with also these kinds of information which is updated continously by the community... a bug fixing assistant to save time?  kind of a workaround until ai is sophisticated enough in 50-100 years so that neural networks can program and debug autonomously...

1 year ago
hmm, the most basic (its a no-brainer really) I can think of spontaneously is a NPE....

say



throws an NPE and you wrote an exception hander for NPEs...

you could write an additional error-message like

"a is null, initialize it or check for null first"

...

or (and thats my opinion)... if the program is smart enough to come up with a solution it could realize the solution as well...

like replace the code above with this:



or something like that...
1 year ago
Hey folks,

I was wondering how it is possible to realize an exeption handling that not only tells you, ok in line 12, 45, 56, ..., 1099 this error, that exception, .... that error ocurred but also suggests solutions to these errors / exceptions.
I tried to google it up but could not find anything useful.... any ideas?

Thanks in advance.
1 year ago
From the API:

https://docs.oracle.com/javase/9/docs/api/java/util/List.html


static <E> List<E> of​()
Returns an immutable list containing zero elements.
static <E> List<E> of​(E e1)
Returns an immutable list containing one element.
static <E> List<E> of​(E... elements)
Returns an immutable list containing an arbitrary number of elements.
static <E> List<E> of​(E e1, E e2)
Returns an immutable list containing two elements.
static <E> List<E> of​(E e1, E e2, E e3)
Returns an immutable list containing three elements.
static <E> List<E> of​(E e1, E e2, E e3, E e4)
Returns an immutable list containing four elements.
static <E> List<E> of​(E e1, E e2, E e3, E e4, E e5)
Returns an immutable list containing five elements.
static <E> List<E> of​(E e1, E e2, E e3, E e4, E e5, E e6)
Returns an immutable list containing six elements.
static <E> List<E> of​(E e1, E e2, E e3, E e4, E e5, E e6, E e7)
Returns an immutable list containing seven elements.
static <E> List<E> of​(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8)
Returns an immutable list containing eight elements.
static <E> List<E> of​(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9)
Returns an immutable list containing nine elements.
static <E> List<E> of​(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10)
Returns an immutable list containing ten elements.



My question is: what's the point of having the methods like for 1, 2, ... 10 elements if there is the varargs method which takes any number of parameters anyway?


static <E> List<E> of​(E... elements)
Returns an immutable list containing an arbitrary number of elements.

1 year ago
Hi,

my question is about following code snippet in the following little test program:



The serial version is quite faster than the parallel version... i was surprised seeing that... can someone explain this?
And in what cases is parallel actually really faster than the serial version of stream?
Or in other words: in what cases do we really benefit from using (parallel) streams?

The program just iterates over a stream and prints its contents to system.out.
And it does the same with a traditional list in a for loop.
At the end it summarizes the results.

Here is the result from an execution :



And here is the code of the program:




Thanks in advance for the input...
1 year ago