|
Okay, I'll try that.
Thanks
(Voted your comment up one)
|
|
|
|
|
hi..how can I define 10 books in a new class...that the books have name,writherName and a code?
then show them to user as a list?
|
|
|
|
|
|
Hey all, I'm not sure where to post this but I hope it's ok to throw it in here. I'm currently learning Scala and I come from more of a Java, C++, Python background. I wrote some code just to sort of figure some stuff out and experiment a bit. I'd love some some feedback, particularly regarding technique and convention and whatnot. The following code will run. I'm doing some simple lazy evaluation of primes. Thanks again.
import scala.collection.mutable.MutableList
import scala.collection.Iterable
import scala.io.{StdIn => input}
object Main {
def main(args: Array[String]): Unit = {
var primeList = MutableList[Int]()
var primeFinder = Iterator.from(2)
nPrimes(primeFinder, primeList)
}
def oneAtATime(primeFinder: Iterator[Int], primeList: MutableList[Int]): Unit = {
println("We are lazily finding all the primes!")
do {
nextPrime(primeFinder,primeList)
println("So far, we have: " + primeList.mkString("[",",","]"))
println("Continue?(press n to quit): ")
} while (input.readLine().toLowerCase() != "n")
}
def nPrimes(primeFinder: Iterator[Int], primeList: MutableList[Int]): Unit = {
println("How many primes would you like to find? ")
val totalPrimes = input.readInt()
for( i <- 1 to totalPrimes) nextPrime(primeFinder, primeList)
println("First "+totalPrimes+" primes: " + primeList.mkString("[",",","]"))
}
def nextPrime(primeFinder: Iterator[Int], primeList: MutableList[Int]): Unit = {
var isPrime = (n: Int, primes: Iterable[Int]) => (primes.takeWhile(p => p*p <= n).forall(n % _ != 0))
var primeVal = primeFinder.next()
while (!isPrime(primeVal,primeList)) primeVal = primeFinder.next()
primeList += primeVal
}
}
|
|
|
|
|
|
hi.
i have to do a code that it will find duplicate element and multiply them to give new array
and if there ist any negative elment muss a Recursion this array correct.
ihope that some one kann help me
thank you
|
|
|
|
|
hi..how can I scan a number from a user..and save it?
|
|
|
|
|
Probably by using some sort of scanning device. But without more information it is impossible to be sure.
|
|
|
|
|
#include <stdio.h>
int main()
{
int number;
printf("Enter an integer: ");
scanf("%d", &number);
printf("You entered: %d", number);
return 0;
}
Output
Enter a integer: 25
You entered: 25
|
|
|
|
|
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
int i = 4;
double d = 4.0;
String s = "HackerRank ";
Scanner scan = new Scanner(System.in);
int i1;
double d1;
String s1;
i1 = scan.nextInt();
d1 = scan.nextDouble();
s1 = scan.nextLine();
s1 = scan.nextLine();
System.out.println(i+i1);
System.out.println(d+d1);
System.out.println(s+s1);
scan.close();
}
}
|
|
|
|
|
import java.util.Scanner;
public class test
{
public static final int SENTINEL = -1;
public static void main(String[] args) {
Scanner kb = new Scanner(System.in);
int score = 0;
int sum = 0;
System.out.println("Enter numbers here");
while (score >= 0) {
if (score <= -1) {
score = kb.nextInt();
sum += score;
score = 0;
}
System.out.println(sum);
}
}
}
|
|
|
|
|
If there are any deadlock cases in production environment, then, how can we identify it?
|
|
|
|
|
Code analysis, unit testing, full testing etc. Try Google (again) to find research papers on the subject.
|
|
|
|
|
Quote: A deadlock occurs when two or more threads in the JVM form a cyclic dependency with each other.
Quote: Click to Tweet
So, How to Diagnose and Troubleshoot Java Deadlocks?
There are various options available to troubleshoot deadlock situations.
1. The naïve way: Kill the process and cross your fingers
You could kill the application server process and hope that when the application server starts again, the problem will go away. However, restarting the application server is a temporary fix that will not resolve the root-cause. Deadlocks could get triggered again when the application server comes back up.
2. The laborious way: Take thread dumps in your cluster of JVMs
You could take thread dumps. To trigger a thread dump, send a SIGQUIT signal to the JVM. (On UNIX, that would be a “kill -3” command and on Windows, that would be a “Ctrl-Break” in the console).
Typically, you would need to capture a series of thread dumps (example: 6 thread dumps spaced 20 seconds apart) to infer any thread patterns – just a static thread dump snapshot may not suffice
modified 5-Dec-18 6:43am.
|
|
|
|
|
hi..I need generate a Random array for make a bank account number. the users can have several account number. I defined account number in a class with name "user". how can i define this in this class and how can I use that in main class? 
|
|
|
|
|
Why a random value? Bank account numbers need to be unique so you should use a sequencing system so each generated number is greater than the previous.
|
|
|
|
|
this is just a class project..so I need get a Random number..random array..how can I?
|
|
|
|
|
|
i want generate some Random numbers..then put them in a array..this array is the bank account numbers for each user..now how can I define this in new class?
|
|
|
|
|
Decide how long the array needs to be and then generate a random value for each element in the array.
|
|
|
|
|
The array is Unknown.. may 1, may 2, may10!!!
|
|
|
|
|
Sorry, I have no idea what that is supposed to mean. Try showing the actual Java code that you are trying to use.
|
|
|
|
|
Is
javascript is overcoming by web assembly language ??
|
|
|
|
|
This forum is for technical issues with Java. Javascript is something totally different, and Google will most likely be the best source for your query.
|
|
|
|
|