Creating random numbers and storing in an array in Java

Java version of this program is given below :
public class Random {
    public static int a[];
    public int l;
    public static int integer(int from, int to){
     return (int) Math.round(Math.random()*(to-from))+from;

public void array(){
    int k=integer(2000,5000);
    a=new int[k];
    for(int i=0;i<k;i++){
public int get_key(){
   int key=integer(2000,5000);
  int index=-1;
   for(int j=0;j<a.length;j++){
       if(a[j]==key) {
  return index;


public static void main (String args[]){
    Random n=new Random();
    System.out.println("Array length is ="+a.length+"....."                          +"Get the key index ="+n.get_key());


Data Structures and Algorithms in Java by Michael T. Goodrich pdf download

Chapter Listing

The chapters for this course are organized to provide a pedagogical path that starts with the basics of Java programming and object-oriented design, moves to concrete structures like arrays and linked lists, adds foundational techniques like recursion and algorithm analysis, and then presents the fundamental data structures and algorithms, concluding with a discussion of memory management (that is, the architectural underpinnings of data structures). Specifically, the chapters for this book are organized as follows:

Data Structures in Java for the Principled Programmer 7 Edition by Duane A. Bailey


YOUR MOTHER probably provided you with constructive toys, like blocks or
Tinkertoys1 or Lego bricks. These toys are educational: they teach us to think
spatially and to build increasingly complex structures. You develop modules
that can be stuck together and rules that guide the building process.
If you are reading this book, you probably enjoyed playing with constructive
toys. You consider writing programs an artistic process. You have grown
from playing with blocks to writing programs. The same guidelines for building

Data Structures & Algorithms in Java pdf

What This Book Is About?

This book is about data structures and algorithms as used in computer programming.
Data structures are ways in which data is arranged in your computer’s memory
(or stored on disk). Algorithms are the procedures a software program uses to
manipulate the data in these structures.
2 Data Structures & Algorithms in Java, Second Edition
Almost every computer program, even a simple one, uses data structures and algorithms.

Copyright © 2010-2019 Java Examples

Designed by Templateism. Built with Blogger Templates.