I have been trying to create a program that outputs four arrays created with random ints doubles chars and booleans. It will compile but when I run still gives me the same variables which have nothing to do with my input at all, but my char array works perfectly.

import java.util.Scanner;
import java.util.Random;

public class Lab12b
{

	static Scanner input = new Scanner(System.in);
	static Random rng = new Random();
	static int intList[];
	static double dblList[];
	static char charList[];
	static boolean booList[];
	
	
	public static void main (String[] args)
	{
		System.out.println("------------------------------------------------------------");
		System.out.println("================ Main Driver Lab 12B =======================");
		System.out.println("------------------------------------------------------------");
		System.out.println();
		System.out.print("How many random variables would you like? ===> ");
		int max = input.nextInt();
		System.out.println();
		System.out.println();
		
		intList = new int[max];
		dblList = new double[max];
		charList = new char[max];
		booList = new boolean[max];
	
		
		createList();
		printList();
		
		
	}
	
        //creating random variables for each slot in the array
	public static void createList()
	{
		for(int i=0;i<intList.length;i++)
		{
			intList[i] = rng.nextInt() + 65;
			dblList[i] = rng.nextDouble();
			charList[i] = (char)( rng.nextInt(26)+65);
			booList[i] = rng.nextBoolean();
		}
	}
	
        //printing out the newly created arrays with their variables
	public static void printList()
	{
		
		System.out.println("------------------------------------------------------------");
		System.out.println("===================== Display List =========================");
		System.out.println("------------------------------------------------------------");
		System.out.println();
		System.out.println(intList);
		System.out.println();
		System.out.println(dblList);
		System.out.println();
		System.out.println(charList);
		System.out.println();
		System.out.println(booList);
		System.out.println();
		System.out.println();
	}
	
}

char array works perfectly

by default. Write own methods to dump arrays.

why1991, the output you are seeing is the default toString() method of class Array being called. When using System.out.println() if you put an object in the parameter it will do whatever that object's toString() method tells it to. Unfortunately for you, that has nothing to do with the data in the array.

What you need to do is what quuba said, write your own method for printing out the data in the array's. There are a couple ways to do this. One way would be to loop through each array, and print out what is at that location. Here is the sun web-page on Array's, you should find it useful.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.