Skip to content
Advertisement

Tag: java

How to make a program show a toast instead of crashing?

I am working on an app. Here’s a small fragment which converts the entered string to a fraction: This works pretty well, provided you enter the number in the correct format. However, if we mess up the format, example, inserted 2 spaces or ‘/’, the app crashes and closes. I want that if the program encounters a problem in this

how to throw an exception to the main method consist of arraylist? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question /Create a method namely callMethod in which display all countries from the arraylist,If more than 5 countries,the method will throw an exception to the main()

How to create a self registering factory in Java?

Factory pattern violates the OCP principle because it uses if() statements, which implies that if any class is added then the factory class has to change, being against SOLID principles. Self registering classes are supposed to address this problem according to this resource: http://www.jkfill.com/2010/12/29/self-registering-factories-in-c-sharp/. The problem is that i don’t know C#. Can someone make an example of this in

Detecting last character

Im trying to detect whether the last character of a string contains an operator using an array checker that was previously used for integers. For some reason the code will always display “Not In” Even …

Disable feign encoding of PathVariables

I have the following Feign Client: The items can contains special characters like : or :: which are being encoded. Request URL becomes something like: https://myservice.com/item/a%3Ab%3A%3Ac Rather than: https://myservice.com/item/a:b::c Can anyone help me understand how can we fix this issue? Answer OpenFeign has an issue tracking: https://github.com/OpenFeign/feign/issues/1190 Guess it will be implemented by spring-cloud-feign once its done. Meanwhile, my workaround

When building an application jar with Maven Shade, is it safe to exclude all META-INF/versions directories/files?

I believe the versions folders are there to support multiple Java versions. We always build for a very specific version (at this time 11). Is there a danger to excluding those directories/files when creating our single application jar? ex. Thanks! Answer Yes, these versions folders are for the support of Multi-Release Jar Files (see JEPS 238). It seems safe to

import org.neo4j cannot be resolved?

I am very new to Neo4j and I’d like to get started with an embedded Neo4j in a Java Application. I try to run a HelloWorld Application as follows. } The Pom code is as follows. Unfortunately I cannot run the code it raises “Exception in thread “main” java.lang.Error: Unresolved compilation problem: at HelloWorldExample.main(HelloWorldExample.java:46)”. Additionally, when hovering over the import

Advertisement