Skip to main content
Filter by
Sorted by
Tagged with
3 votes
0 answers
99 views

Assume there is a base class in a Java library which cannot be modified public class BaseClass { public Something function(int... args){ ... } } Typically, this would be overridden in Scala by ...
Ian Bertolacci's user avatar
0 votes
3 answers
147 views

How to convert the following scala to java code? for { x <- List(1, 2) y <- List(3, 4) } yield (x, y) Is it possible? what is yield? I guess it's possible to convert any scala code to java.....
J.J. Beam's user avatar
  • 3,171
1 vote
1 answer
97 views

The scala project is depending on the Java lib that I cannot modify. I need to extend one of the Java classes and override method, however I have issues with protected visibility: package com.a; ...
Hedrack's user avatar
  • 786
2 votes
1 answer
73 views

I hava a Java interface: public interface FooJava { void consume(String... strings); void consume(Integer... ints); } and I want to implement it in Scala: class BarScala extends FooJava { ...
Lesiak's user avatar
  • 26.5k
0 votes
1 answer
64 views

I hava a Java interface: public interface FooJava<Element> { void consume(Element[] elements); // more methods } and I want to implement it in Scala: // attempt 1 class BarScala[T] extends ...
Lesiak's user avatar
  • 26.5k
0 votes
1 answer
134 views

trying to use in java class defined in scala library. Definition: final class ScenarioBuilder(...) extends StructureBuilder[ScenarioBuilder] trait StructureBuilder[B <: StructureBuilder[B]] extends ...
Oleksii Pylypchuk's user avatar
0 votes
0 answers
26 views

want to iterate thru bidChoices list and map using scala, below is the java code. what to perform the same using scala. private String generateRestBody(String baseUrl, String auctionId, String ...
Banu's user avatar
  • 47
0 votes
1 answer
177 views

I'm refreshing scala. This looks very simple to me but I can't get it to run: import java.nio.file.{FileSystems, Files} object ScalaHello extends App { val dir = FileSystems.getDefault.getPath(&...
diegoruizbarbero's user avatar
0 votes
0 answers
142 views

Consider the following scala class: class Demo { def mandatoryInt: Int = 42 def optInt: Option[Int] = Some(1) def optString: Option[String] = Some("demo") } When its methods are ...
Roman's user avatar
  • 66.4k
0 votes
1 answer
728 views

I have an object within another object in Scala which I want to import in Java. The setup is something like this: Scala: package scalapart; object Outer { object Inner { def method: ...
David Nemeskey's user avatar
3 votes
2 answers
155 views

Many years of using Scala and still I don't know the right way to interoperate with Java. :( To be honest, this is not something that I'm doing every day, but sometimes there is no other option (today ...
angelcervera's user avatar
  • 4,259
1 vote
1 answer
230 views

I have a Java interface that I want to implement in Scala. The interface contains the following method-declaration: List<Map<String, Object>> xyz(Map<String, Object> var1, Map<...
kiran's user avatar
  • 53
0 votes
2 answers
146 views

I've scala - java polyglot project with scala version 2.13 Below is the standard project structure $scala-java-extend-demo on master ± tree . . ├── build.gradle.kts ├── gradlew ...
user51's user avatar
  • 10.6k
2 votes
0 answers
173 views

this is pretty much the code setup: // java public class JavaA { } // scala class ScalaA() extends JavaA { } but then in java, if i have an instance of ScalaA somewhere (or even if its null), but ...
REghZY's user avatar
  • 68
2 votes
1 answer
302 views

A Scala code has a retry mechanism which is based on currying function: object RetryUtil { def retry[T](retry: Int, timeout: FiniteDuration)(exc: => T): T = { // } } I want to call this code ...
Johnny's user avatar
  • 15.6k
1 vote
2 answers
590 views

let's consider: public class Text extends BinaryComparable implements WritableComparable<BinaryComparable> { We can see that Text is BinaryComparable. Then, let's consider @...
tomek.xyz's user avatar
  • 139
1 vote
0 answers
208 views

I have a normal Java class BaseModel as below @AllArgsConstructor class BaseModel { private String id; } Now I want to extend this in scala case class. Below is giving error: case class Employee(...
Suman's user avatar
  • 868
0 votes
1 answer
733 views

import scala.collection.JavaConversions._ val j: java.util.Map[String, String] = Map("a" -> "b") print (j) How does it work? In other words I am dying to know how import of ...
tomek.xyz's user avatar
  • 139
1 vote
1 answer
206 views

I have scala class like: class A { object B { def c(d: Int) = d + 4 } } How do i access function c from a java code? Edit: assume that I can't change scala class anyhow. Edit#2: Here is ...
Vasilisck's user avatar
  • 105
0 votes
1 answer
340 views

Is there a way that I can use the fromJson and toJson methods in my java code? I would want to call it to transform a bson document that I get from mongoldb to a model class that I have in Scala My ...
Adi Kish's user avatar
-4 votes
1 answer
164 views

type mismatch; found : String => Int required: java.util.function.ToIntFunction[_ >: String] I really do wish before people wrote up the "next big thing" they got a few ...
bharal's user avatar
  • 16.4k
1 vote
2 answers
340 views

I want that the if block returns Right(List[PracticeQuestionTags]) but I am not able to do so. The if/else returns Either //I get java.util.List[Result] val resultList:java.util.List[Result] = ...
Manu Chadha's user avatar
  • 16.9k
3 votes
2 answers
314 views

Currently, my main application is built with Java Spring-boot and this won't change because it's convenient. @Autowired service beans implements, for example : Enterprise and establishment datasets. ...
Marc Le Bihan's user avatar
2 votes
2 answers
528 views

Bear with me, I understand this is a weird problem to have. I have just stumbled across Java's reflection library, specifically this bit of code from a video by Lex Fridman which overrides 2 + 2 = 5: ...
James Whiteley's user avatar
1 vote
2 answers
395 views

I have defined the class A in Scala: class A(var number: Int) But when I try to access its member field number in java, I get an error: A a = new A(); a.number = 4; Results in: java: number has ...
SørenHN's user avatar
  • 706
1 vote
1 answer
129 views

In Java, we have defined an ObservableCollection.java like this: public class ObservableCollection<T> implements Collection<T> { public SubscriptionHandle onElementAdded(Consumer<T&...
Florian Baierl's user avatar
0 votes
1 answer
853 views

I’m currently working within a java runtime google cloud dataflow. The scala sdk I'm using shows the property I'm working with as an immutable list: https://github.com/snowplow/snowplow-scala-...
Jesse's user avatar
  • 8,423
1 vote
0 answers
320 views

I'm a beginner programmer working within a mixed Java/Scala codebase. I have a implicit class in Scala that provides extensions to a class within a third-party dependency. The implicit class is as so: ...
hpabst's user avatar
  • 416
0 votes
2 answers
129 views

From my understanding the ultimate class in Scala is Any class. However, I thought Scala built of the Java, so would not the ultimate class be Object? I have been checking the documentation and I ...
VividMan's user avatar
0 votes
1 answer
268 views

Given a Java interface interface Value { Value add(Value argument); } (since Java does not support symbols like + as method names), is it possible to define an alias method + to alias add such ...
Christian Fries's user avatar
0 votes
1 answer
325 views

How can I extends a Java class that expects a Map<?, ?> in its constructor in Scala? The Java class looks like public class MyJavaClass { private final Map<String, ?> originals; ...
Michael Heil's user avatar
  • 18.8k
0 votes
3 answers
414 views

I have a java method which is accepting predicate(Predicate<T> predicate) my java class is class Employee { String getEmployeeId() { return ""; } boolean isManager() { return ...
dinesh c's user avatar
4 votes
2 answers
442 views

How do I do a contains allOf assertion on a Java Map? The following did not work val testMap = new java.util.LinkedHashMap[Int, Int]() testMap.put(1,2) testMap.put(2,4) testMap.put(3,6) testMap ...
Gabriel's user avatar
  • 1,783
1 vote
0 answers
544 views

Getting the following error : java.lang.NoSuchMethodError:scala.Predef$.wrapRefArray([Ljava/lang/Object;)Lscala/collection/mutable/WrappedArray; I'm not sure about the nature of the error but I ...
samuel vishal's user avatar
2 votes
1 answer
2k views

I have been using scala.collections.JavaConversions for implicitly converting, but decided to upgrade the scala version and use scala.collections.JavaConverters instead, I'm confused with the explicit ...
samuel vishal's user avatar
0 votes
1 answer
951 views

I have a simple method to retrieve a nested key from a hashmap. I need to pattern match on Map[String,Any] so that I can keep iterating into the nested data until I get to a flat value: def get(map: ...
user's user avatar
  • 432
1 vote
2 answers
281 views

Here is the code snippet : protected static List<String> myclass(String mydata){ scala.collection.Set<String> abc = <**some code that returns set of strings**(scala code)> ...
Question Mark's user avatar
0 votes
0 answers
120 views

I am trying to use a Java library (Hipster) with Scala. Running the example on the front page, I get this type error message which I can't make sense of: My attempt so far was to try convert Java <...
Guillaume's user avatar
  • 1,286
3 votes
1 answer
2k views

after few days of search, I need your help to solve my problem. I have a java program and I want to call a library written in scala, the jar is in classpath. Scala main class: object Program{ def ...
wmebrek's user avatar
  • 33
1 vote
1 answer
169 views

In my java code I am using a method, let's call foo(), that returns a scala.Double[]. scala.Double[] arr = foo(); I want to sum up arr into a scala.Double, but am having trouble. I've found that ...
Mike S's user avatar
  • 1,673
12 votes
3 answers
3k views

val i: java.lang.Integer = null val o: Option[Int] = Option(i) // This yields Some(0) What is the safe way to convert null: java.lang.Integer to Scala Option[Int]?
anandhu sreekumar's user avatar
1 vote
0 answers
77 views

I have a trait with generic and two alternative methods for checking age and name of employee. trait Conditions[T] { def nameIs(color: String): T def ageUpperThan(upper: Int): T } def ...
Vadim's user avatar
  • 835
2 votes
1 answer
141 views

CollectionConverters API states In all cases, converting from a source type to a target type and back again will return the original source object. This does not seem to be always true. For ...
Mario Galic's user avatar
  • 48.6k
3 votes
1 answer
214 views

I have a Scala class which has two overloaded set methods, one with an Array param and the other with varargs. I want to call these methods from Java side, I am facing some issues due to overloading ...
Dollyg's user avatar
  • 337
1 vote
1 answer
1k views

If I have a case class like this: case class Foo(s : String, k : Int) How do I specify an empty constructor for this? The reason I need this is because I want to pass this class value to a Java API ...
Mojo's user avatar
  • 1,222
3 votes
1 answer
554 views

I am quite familiar with Java and Maven, but not at all with Scala. I am trying to access Scala from Java and one of the problems I can't seem to understand is the following: My Question In ...
Sonke W's user avatar
  • 147
0 votes
1 answer
455 views

I have a n-quantity of Java classes with one superclass - data model. The list of the classes is input parameter to Scala method in which I want to create resultStreams and have to create call Java ...
Vadim's user avatar
  • 835
4 votes
1 answer
131 views

AFAIU, CollectionConverters are wrappers simply delegating calls to the underlying collection, thus the cost should be single object allocation and then single method call indirection, for example, ...
Mario Galic's user avatar
  • 48.6k
2 votes
1 answer
550 views

I'm trying to implement a method that will calculate & validate the HmacSHA256 signature for verifying a slack request. For... various reasons... I'm using scala.js, and therefore I don't have ...
Tobias Roland's user avatar
7 votes
1 answer
520 views

This is my very first question down here, so i'll try to make it clear as far as i can. Other error: type mismatch; questions here are not related to this error. I have this odd problem with scala/...
thevpc's user avatar
  • 73

1
2 3 4 5
7