shivanyy gupta

Ranch Hand
+ Follow
since Dec 27, 2017
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
(keep public parts private until JForum day)
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by shivanyy gupta



Can anybody explain me the pictorial representation of this code. How s1 refers to an object of s2.
What does m(this) internally mean?
What S2 obj refers to??
1 week ago

Paul Clapham wrote:Yes, if there was an array with 100 elements in the ArrayList and it was necessary to extend it, then an array with 200 elements is created and the 100 elements are copied from the old array into the new array. The old array is just left to be garbage collected.



Yes, this is main thing i am looking for. I was not sure on, when the resizing will be done then these 2 operations are done or not:
1. Old array elements are copied in to the newly created resized array.
2. The old array after copying will be left for GC.

Thanks a lot
1 week ago
Hi Everyone,

I know the basics of Array and Arraylist class in Java but a bit confused with the performance of ArrayList if resizing is required.
During resizing, a new array has been allocated along with the existing array. So what would happen to the previous array. Does it mapped again after resizing ? Please help me in this with similar type of questions?
Just want to understand the performance hit of Arraylist during resizing when compared with a fixed size array.


Thanks in Advance
1 week ago

Liutauras Vilda wrote:Please post how the code looks like you have started and got stuck on.



Hi, I just thought of an approach for doing this.
Converting my Arraylist in to an Array and then printing the array indexes.

Object[] objects = al.toArray();

        // Printing array of objects
        for (Object obj : objects)
            System.out.print(obj.getidentity[0] + " ");  //The problem here is to how to maintain the index
            System.out.print(obj.getidentity[1] + " ");  
            System.out.print(obj.getidentity[2] + " "); 
    }
2 weeks ago
Hi Everyone,

I have one question related to Arraylist. Suppose you have an Arraylist of Person.



Now my requirement is to print the arraylist objects in this tabular format.
Serial no.    1           2                    3              4
age            20         52                  19             27
name         ABC      XCV               ERTY         GHTUJ
salary         50K       71K               85K             10K
identity       P44        P85               P90              P32

How would i print such format on the screen.

Thanks
2 weeks ago
Hi Everyone,

I know what a singleton pattern is and i also know that logging is an example of Singleton. Can somebody help me identifying scenario(s) where singleton can be proved as a cherry on a cake. I am looking for some real time, project specific scenario examples where we can use singleton design pattern. Assume that i am working on a banking (Le'ts say RBS) or telecom project (bharti airtel).
3 weeks ago

Rob Spoor wrote:What container are you using? Not al containers provide Jersey for you. Jetty and Tomcat don't provide any JAX-RS framework implementation, and last I checked WildFly and JBoss provided RESTEasy instead of Jersey. WebLogic 12.1 provides an older version of Jersey that uses com.sun.jersey as base package, not org.glassfish.jersey (that's Jersey 2.x).



I am using Apache Tomcat version 8 with Eclipse Mars 2.0. Working on Java 8 update 151. I am creating a maven project
1 month ago
Hi Everyone,

I am totally stuck in one issue for the whole day now. I am trying to run a basic helloworld REST service using Jersey API but i am stuck on java.lang.ClassNotFoundException: org.glassfish.jersey.servlet.ServletContainer Exception.
Web.xml



HelloWorldService.java




The url i am hitting is : http://localhost:9090/RESTfulExample/rest/hello/shivany


I am using JDk 8 with 2.26 Jersey

Please help
1 month ago
Hi Everyone,

Although i am done with the basics of Concurrent HashMap, but still it would be better if some one can point some areas where i can practice some actual scenarios with CHM.
Being a trainer in MNC, the objective is to deliver the best knowledge to the trainees. Can someone share some idea or project code that can actually shows the usage of CHM.
The example should be something which makes a better understanding and trainees can show me a small project on that, so that they can actually be productive while working in the real scenario.
Thanks in advance.
1 month ago

thanks for all the information. Can you please specify how i am getting this output. What is the value for this.id in each traversal. I want to know the value of this.id in each traversal
1 month ago
Hi Everyone,

I was stuck in understanding my piece of code. Let me share the code first.






Now my question series starts,
1. When i run this code, i got output as :
The difference of this id and other id is..** 6  other id**1
The difference of this id and other id is..** 3  other id**6
The difference of this id and other id is..** 3  other id**6
The difference of this id and other id is..** 3  other id**1
The difference of this id and other id is..** 11  other id**3
The difference of this id and other id is..** 11  other id**6
[Employee [name=lalit, id=1], Employee [name=zanjan, id=3], Employee [name=rmit, id=6], Employee [name=harjot, id=11]]

My question is how the comparison would be between 6 & 1.
How number 6 is assigned to this.id ?
What is the need of comparing 3 & 6 two times? in the second and third line of output.
How actually compareTo method works, means how this subtraction leads to sorting using Comparable.

1 month ago

shivanyy gupta wrote:

Liutauras Vilda wrote:@OP

Would you mind to describe the goal in general what are you trying to do?
As both guys already indirectly mentioned, to get into technical details and even choose tools might be too early if isn't fairly clear what is the exact goal.

There are many different ways to read file, either use already created libraries by somebody else, either write some code yourself (write them in various ways).

One of ways to read file in Java 8 (you'd need to handle exception probably):
Now that you have a stream, you could apply forEach() method and do something with each of the lines.



I task is to simply read that file and perform some addtions/subtractions operations on them. But i may got different records with each file. One time i got one file.



For example, i have a file say Test.csv having 5 headers A,B,C,D,E and my job is to perform add operation on A, Subration operation on B, Multiplication on C and so on.
A    B    C    D     E
10  20  30  40    50
10  20  30  40    50


So, the output would be
A    B    C      D     E
30   0   900   1    any value


1 month ago

Liutauras Vilda wrote:@OP

Would you mind to describe the goal in general what are you trying to do?
As both guys already indirectly mentioned, to get into technical details and even choose tools might be too early if isn't fairly clear what is the exact goal.

There are many different ways to read file, either use already created libraries by somebody else, either write some code yourself (write them in various ways).

One of ways to read file in Java 8 (you'd need to handle exception probably):
Now that you have a stream, you could apply forEach() method and do something with each of the lines.



I task is to simply read that file and perform some addtions/subtractions operations on them. But i may got different records with each file. One time i got one file.
1 month ago