This week's book giveaways are in the Angular and TypeScript and Web Services forums.
We're giving away four copies each of Programming with Types and The Design of Web APIs and have the authors on-line!
See this thread and this one for details.
Win a copy of Programming with Types this week in the Angular and TypeScript forum
or The Design of Web APIs in the Web Services forum!

Sibi Varghese

Greenhorn
+ Follow
since Jan 09, 2020
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
1
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sibi Varghese

I was able to fix the Java 8 issue by configuring each project by right clicking and
selecting Build Path/Configure Build Path. Then under Libraries had to change Modulepath
to JavaSE-18 and Classpath select jdk 1.8.0_221. I hope no other issue I will face while
working with Selenium since, I have Java 8 configured
4 days ago
I had JDK 13 but, I downgraded to JDK 8 and also installed the prequisites from the this website: http://autotechnotes.weebly.com/prereq.html

then, Set Environment Variables as show on the weebly website for Java 8 (JDK8)

As per previous screenshot file name : RandomNumberNth.java

Below are some errors underlined in 'RED'
*************************************


Line 1 : java.util

Error: The import java.util can not be resolved


Line 2 : RandomNumeberNth

Error: Implicit super constructor Object() is undefined for default constructor. Must define an explicit constructor.


Line 3 : String

Error: String cannot be resolved to a type

*************************************
Error on Line 1

underlined in red  'Random'
error : Random cannot be resolved to a type.  



As I said earlier when I installed JDK 13 back on the Java projects worked perfectly with no errors unlike Java 8 (JDK 8).

Someone told me to reconfigure the run configuration and choose java 8 not sure about it but, I see run configuration under 'Run' tab.

Let me know if there a way fix this issue unable to run Java projects on JDK 8.
4 days ago
JDK 8 was installed and uninstalled latest version JDK 13 to work on Selenium.
But, I was unable runs any Java Projects as you can see the screenshot.
The issue was resolved after reinstalling the latest JDK 13 again but,
by keeping both JDK 8 and JDK 13 it will cause issues with running Selenium down the road
so, is there a solution to this issue to get fix for using JDK 8 for both Java and Selenium.



4 days ago
This code is to print duplicate character of a given String.
What does the logic behind these lines of code. Why there are two 'if' statements :                                

if (!duplicates.contains(String.valueOf(str.charAt(j)))) {
                           duplicates += str.charAt(j);
Can someone please explain lines 18 and 19?    
1 week ago
@Knute Snortum          
         int startcounter=100;  // Do I keep startcounter on '0' if I have generate 500 random numbers
   int n=0; // This is initial value of n and later it incremented as n++ and initialized as variable 'c'
 int endCounter=500;
 int arraysize = endCounter-startcounter; // this defines the array size, basically of 500 random numbers  
 int numbers[] = new int[arraysize+1]; Declaring integer array for variable 'numbers' equal to new integer[size of array +1]

Please correct my understanding. Thanks in advance.

Sibi Varghese wrote:Awesome!!! Knute Snortum. Thanks a lot.

Knute Snortum wrote:You've already been told to UseCodeTags (that's a link) when you post code.

1)  int endCounter=500; - Do I keep this 500 since, I'm generating 500 numbers


Yes.  

2)  this part of the code :
        int c = n++;
int num = rnum.nextInt(1000);
numbers[c]= num;

Some confusion with these lines of code : 1) basically you are declaring int variable 'c' and the value is incremented as n++ 2) Generates integer to be printed and return a number within > =1000 - int num = rnum.nextInt(1000); 3) numbers[c]= num; creating a array and assigning to num. Please correct my understanding.


1) Not quite.  Since the ++ is after the variable name, you use the variable first, then increment it.  So c gets n than n get incremented.

2) Almost.  nextInt(1000) will create an integer from 0 to 999.

3) No.  The array numbers has already be defined.  numbers[c]= num; assigns num to numbers at index c.

1 week ago
Awesome!!! Knute Snortum. Thanks a lot.

Knute Snortum wrote:You've already been told to UseCodeTags (that's a link) when you post code.

1)  int endCounter=500; - Do I keep this 500 since, I'm generating 500 numbers


Yes.  

2)  this part of the code :
        int c = n++;
int num = rnum.nextInt(1000);
numbers[c]= num;

Some confusion with these lines of code : 1) basically you are declaring int variable 'c' and the value is incremented as n++ 2) Generates integer to be printed and return a number within > =1000 - int num = rnum.nextInt(1000); 3) numbers[c]= num; creating a array and assigning to num. Please correct my understanding.


1) Not quite.  Since the ++ is after the variable name, you use the variable first, then increment it.  So c gets n than n get incremented.

2) Almost.  nextInt(1000) will create an integer from 0 to 999.

3) No.  The array numbers has already be defined.  numbers[c]= num; assigns num to numbers at index c.

1 week ago
This code I got worked out from someone online:

import java.util.Random;
public class RandomNumeberNth {

 public static void main(String[] args) {

 int startcounter=100;
 int n=0;
 int endCounter=500;
 int arraysize = endCounter-startcounter;
 int numbers[] = new int[arraysize+1];
 Random rnum = new Random();
 System.out.println("Random Numbers\n****************");
     for(int counter=startcounter;counter<=endCounter;counter++)
 {
 int c = n++;
 int num = rnum.nextInt(1000);
 numbers[c]= num;
 System.out.println(numbers[c]);

 }
 int smallest = numbers[0];
               int biggest = numbers[0];

               for(int i=1; i< numbers.length; i++)
               {
                       if(numbers[i] > biggest)
                               biggest = numbers[i];
                       else if (numbers[i] < smallest)
                               smallest = numbers[i];
               }
               System.out.println("Largest Number is : " + biggest);
               System.out.println("Smallest Number is : " + smallest);
}
}

so, I had few questions on some lines of code

1)  int endCounter=500; - Do I keep this 500 since, I'm generating 500 numbers

2)  this part of the code :
         int c = n++;
 int num = rnum.nextInt(1000);
 numbers[c]= num;

Some confusion with these lines of code : 1) basically you are declaring int variable 'c' and the value is incremented as n++ 2) Generates integer to be printed and return a number within > =1000 - int num = rnum.nextInt(1000); 3) numbers[c]= num; creating a array and assigning to num. Please correct my understanding.
1 week ago
1) Generate 500 Random number range from 100 – 1000



2) Nth smallest number



How can I merge both into one code so, that after generating 500 random number b/w 100-1000, the next code should print the Nth smallest number.
Can someone please help me with the right logic to solve this.

Thanks

1 week ago