I'm having difficulty passing arrays between methods, I've managed to set them all to false from boolean, and returned the array to the main. However from there I don't know how to pass it to another method, and then later display the boolean true array as "yes" or the boolean false array as "no". My code looks as follows:
import javax.swing.*;
class methodarrays
{
public static void main (String[]param)
{
arrays();
seen();
display();
}
public static boolean[] arrays()
{
boolean [] birds = new boolean [5];
for (int i=0;i<birds.length;i++)
{
birds[i]=false;
}
return birds;
}
public static boolean seen()
{
String quit = "100";
String ans = "";
while(!ans.eqauls(quit))
{
ans=JOptionPane.showInputDialog(null,"Which bird are you reporting? \n 1) Blue Tit 2) Blackbird 3)Robin 4)Wren 5)Greenfinch");
if (ans.equals("1"))
{
birds[0] = true;
return birds[0];
}
else if (ans.equals("2"))
{ birds[1] = true;
return birds[1];
}
else if (ans.equals("3"))
{
birds[2] = true;
return birds[2];
}
else if (ans.equals("3"))
{
birds[2] = true;
return birds[2];
}
else if (ans.equals("4"))
{
birds[3] = true;
return birds[3];
}
else if (ans.equals("5"))
{
birds[4] = true;
return birds[4];
}
}
}
public static void display()
{
JOptionPane.showMessageDialog(null,"Your Garden Watch results are:");
}
}
To give you are starting hand... you can set the result of your arrays method to a local variable in the main method and pass as a argument to the seen. Then you can do the same for the display method.
public static void main (String[]param)
{
boolean[] birds = arrays();
seen(birds);
display(birds);
}
public static boolean[] arrays()
{
...
}
public static boolean seen(boolean[] birds)
{
...
There are plenty of tutorials around the web for this kind thing. Here being one example.
You need to pass it as a parameter or declare a global array.
Passing by parameter:
class methodarrays {
public static void main (String[]param)
{
boolean [] myArray =arrays();
seen(myArray);
display(myArray);
}
public static boolean seen(boolean [] myArrayParam)
{
for (int i=0;i<myArrayParam.length;i++)
{...}
}
public static boolean display(boolean [] myArrayParam)
{
for (int i=0;i<myArrayParam.length;i++)
{...}
}
}
As global array:
class methodarrays {
boolean [] myArray
public static void main (String[]param)
{
myArray = arrays();
seen();
display();
}
public static boolean seen()
{
for (int i=0;i<myArray.length;i++)
{...}
}
public static boolean display()
{
for (int i=0;i<myArray.length;i++)
{...}
}
}
Declare
boolean [] birds = new boolean [5];
as accessible object for all methods within your class.
import javax.swing.*;
class methodarrays
{
private boolean [] birds = new boolean [5]
...
public static boolean[] arrays()
{
for (int i=0;i<birds.length;i++)
{birds[i]=false;
}
return birds;
}
...
}
Here is the implementation mimicing your own:
import javax.swing.JOptionPane;
public class Example {
private static boolean [] birds = new boolean [5];
public static void main (String[]param){
arrays();
seen();
display();
}
public static boolean[] arrays()
{
// Completely unnecessary since values are set to false by default;
for (int i=0;i<birds.length;i++)
{birds[i]=false;
}
return birds;
}
public static void seen(){
String quit = "100";
String ans = "";
while(!ans.equals(quit))
{
ans=JOptionPane.showInputDialog(null,"Which bird are you reporting? \n 1) Blue Tit 2) Blackbird 3)Robin 4)Wren 5)Greenfinch");
if (ans.equals("1"))
{ birds[0] = true;
}
else if (ans.equals("2"))
{ birds[1] = true;
}
else if (ans.equals("3"))
{ birds[2] = true;
}
else if (ans.equals("3"))
{ birds[2] = true;
}
else if (ans.equals("4"))
{ birds[3] = true;
}
else if (ans.equals("5"))
{ birds[4] = true;
}
}
}
public static void display(){
System.out.println("Your results are: ");
System.out.println("Blue Tit: " + birds[0]);
System.out.println("Blackbird: " + birds[1]);
//and so on..
}
}
Related
I'm trying to write the best algorithm to solve the problem. Can a given String be formed with a given array of String?
I've tried multiple solutions but the execution time exceed my requirements.
import java.util.ArrayList;
import java.util.Scanner;
public class JavaApplication5 {
static boolean encontrado;
static ArrayList<String> tp=new ArrayList<>();
static ArrayList<String> ts=new ArrayList<>();
public static void main(String[] args) {
tp.add("H");
tp.add("B");
ts.add("HE");
ts.add("LI");
Scanner t=new Scanner(System.in);
while(t.hasNext()){
encontrado=false;
String f=t.nextLine().replaceAll(" ","").toUpperCase();
if(calcular(f,0)){
System.out.println(YES");
}else{
System.out.println("NO");
}
}
}
private static boolean calcular(String f,int pos) {
if(f.length()>pos&&!encontrado){
if(tp.indexOf(String.valueOf(f.charAt(pos)))!=-1){
if(pos==f.length()-1){
encontrado=true;
}else{
calcular(f,pos+1);
}
}
}
if(f.length()>pos+1&&!encontrado){
if(ts.indexOf(String.valueOf(f.charAt(pos))+String.valueOf(f.charAt(pos+1)))!=-1){
if(pos+1==f.length()-1){
encontrado=true;
}else{
calcular(f,pos+2);
}
}
}
return encontrado;
}
}
Expectations
arrayString={"A","B","CD"}
A.s="ACDBB"-->POSSIBLE
B.s="DCAAB"-->NOT POSSIBLE
Try something like this:
public class Test {
static String[] arrayString = new String[] {"A","B","CD"};
static boolean possible(String str) {
if (str.length() == 0) {
return true;
}
for (String component : arrayString) {
if (str.startsWith(component)) {
String shorterStr = str.substring(component.length());
if (possible(shorterStr)) {
return true;
}
}
}
return false;
}
static void test(String str) {
String result = (possible(str) ? "" : "NOT ") + "POSSIBLE";
System.out.println(str + " -> " + result);
}
public static void main(String[] args) {
test("ACDBB");
test("DCAAB");
}
}
I am trying to understand the Memento Pattern. For that purpose i am trying to implement the undo function. The problem is that when ever i save the old state of the originator in the queue and run a different function the save state changes to the current state. I really need help to understand what i am doing wrong. How can i make the vector to be immutable.
This is the memento class.
package memento;
public class Memento
{
private final boolean[] vectorState;
public Memento(boolean[] vector) {vectorState = vector;}
boolean[] getMemento() { return vectorState;}
}
The Originator just need to shift a vector of boolean to the left.
(TRUE,FALSE,FALSE) shift left returns: (FALSE,FALSE,TRUE). This is the implementation.
package memento;
public class ShilftLeftOriginator
{
private boolean[] vector;
public ShilftLeftOriginator(boolean[] vector) {this.vector = vector;}
public void execute()
{
final boolean firstValue = this.vector[0];
for (int i = 1; i < this.vector.length; i++) {
this.vector[i - 1] = this.vector[i];
}
this.vector[vector.length - 1] = firstValue;
}
public Memento saveToMemento() {return new Memento(vector);}
}
And the caretaker:
package memento;
import java.util.Arrays;
import java.util.Deque;
import java.util.LinkedList;
public final class BooleanVector {
private boolean[] vector;
private Deque<Memento> mementoList = new LinkedList<>();
public BooleanVector(boolean[] inputValues) {
this.vector = inputValues;
}
#Override
public boolean equals(Object obj)
{
if (obj == null) return false;
if (!(obj instanceof BooleanVector)) return false;
BooleanVector otherVector = (BooleanVector) obj;
return Arrays.equals(this.vector, otherVector.vector);
}
public void shiftLeft()
{
ShilftLeftOriginator shiftLeft = new ShilftLeftOriginator(vector);
mementoList.add(shiftLeft.saveToMemento());
shiftLeft.execute(); // This is my Problem. After execute ist call the value(vector) in mementoList changes
}
public void undo(){ this.vector = mementoList.pop().getMemento();}
}
And now the test class and the error that i am receiving.
package memento;
public class Main {
public static void main(String[] args) {
boolean[] inputValues = { false, true, false };
BooleanVector vector = new BooleanVector(inputValues);
vector.shiftLeft();
boolean[] expectedValues = new boolean[] { true, false, false };
BooleanVector expectedVector = new BooleanVector(expectedValues);
if (!vector.equals(expectedVector)) {
throw new IllegalStateException(vector.toString());
} else {
System.out.println("shiftleft working");
}
vector.undo();
expectedValues = new boolean[] { false, true, false };
expectedVector = new BooleanVector(expectedValues);
if (!vector.equals(expectedVector)) {
throw new IllegalStateException(vector.toString());
} else {
System.out.println("undo working");
}
}
}
The console output:
shiftleft working
Exception in thread "main" java.lang.IllegalStateException: [true, false, false]
at memento.Main.main(Main.java:26)
The problem is that you're always manipulating the same array. So if you shift left, you also shift left the array you stored in the Memento object, because it's all the same array.
To solve it, make a copy of the array in the constructor of the Memento object:
public Memento(boolean[] vector) {
vectorState = Arrays.copyOf(vector, vector.length);
}
Aside from that, you seem to have your classes mixed up. BooleanVector and ShilftLeftOriginator are the originator, while Main is the caretaker.
I can give you a little bit more expandable solution:
class Originator: abstract implementatino of the value T holder
public abstract class Originator<T> {
private T value;
private final CareTaker<T> careTaker;
protected Originator(T value, CareTaker<T> careTaker) {
this.value = value;
this.careTaker = careTaker;
}
public final T getValue() {
return value;
}
protected final void setValue(T value) {
careTaker.add(this.value);
this.value = value;
}
public final void undo() {
if (!careTaker.isEmpty())
value = careTaker.remove();
}
}
class BooleanVector: concrete implementation that holds boolean[]
public final class BooleanVector extends Originator<boolean[]> {
public BooleanVector(boolean[] obj) {
super(obj, new CareTaker<>());
}
public void leftShift() {
if (getValue() == null || getValue().length == 0)
return;
boolean[] arr = new boolean[getValue().length];
boolean tmp = arr[0];
System.arraycopy(getValue(), 1, arr, 0, getValue().length - 1);
arr[arr.length - 1] = tmp;
setValue(arr);
}
}
class CareTaker: implementation of values change history - memento
public final class CareTaker<T> {
private final Deque<Item<T>> stack = new LinkedList<>();
public void add(T value) {
stack.push(new Item<>(value));
}
public T remove() {
return stack.pop().data;
}
public boolean isEmpty() {
return stack.isEmpty();
}
private static final class Item<T> {
private final T data;
public Item(T data) {
this.data = data;
}
}
}
Demo:
public static void main(String[] args) {
BooleanVector originator = new BooleanVector(new boolean[] { false, true, false });
System.out.println(Arrays.toString(originator.getValue()));
System.out.println("---");
originator.leftShift();
System.out.println(Arrays.toString(originator.getValue()));
originator.undo();
System.out.println(Arrays.toString(originator.getValue()));
}
Output:
[false, true, false]
---
[true, false, false]
[false, true, false]
I am creating an example login app. For some reason when I call the method checkFinal in my main method it is giving me an error. It says that it needs to call the booleans which check the username and the password. Which I did. It says that they can not be passed through. I do not know if this is an pass by value or a pass by reference issue. I have all of the other code working.
import java.util.Scanner;
public class program {
private static Scanner a;
private static String inputusername;
private static Scanner b;
private static String inputpassword;
private static String validusername;
private static String validpassword;
public static void main(String[] args) {
greeting();
questiona();
questionb();
username();
password();
checkOne(validusername, inputusername);
checkTwo(validpassword, inputpassword);
checkFinal(usernamecheck, passwordcheck);
}
public static void greeting() {
System.out.println("Hello!");
System.out.println("Note: All Things Are Case Sensitive!");
}
public static String questiona() {
System.out.println("What Is Your Username?");
a = new Scanner(System.in);
inputusername = a.next();
return inputusername;
}
public static String questionb() {
System.out.println("What Is Your Password");
b = new Scanner(System.in);
inputpassword = b.next();
return inputpassword;
}
public static String username() {
validusername = "username";
return validusername;
}
public static String password() {
validpassword = "password";
return validusername;
}
public static boolean checkOne(String validusername, String inputusername) {
boolean usernamecheck = false;
if (validusername == inputusername) {
usernamecheck = true;
}
return usernamecheck;
}
public static boolean checkTwo(String validpassword, String inputpassword) {
boolean passwordcheck = false;
if (validpassword == inputpassword) {
passwordcheck = true;
}
return passwordcheck;
}
public static boolean checkFinal(boolean usernamecheck, boolean passwordcheck) {
boolean checkFinal = false;
if (usernamecheck == true && passwordcheck == true) {
checkFinal = true;
} else {
checkFinal = false;
}
return checkFinal;
}
public static void compile(String[] args) {
}
public static void server(String[] args) {
}
}
You have to assign these two method results to variables:
boolean usernamecheck = checkOne(validusername, inputusername);
boolean passwordcheck = checkTwo(validpassword, inputpassword);
checkFinal(usernamecheck, passwordcheck);
usernamecheck is a local variable in checkOne
passwordcheck is a local variable in checkTwo
in your main checkFinal(usernamecheck, passwordcheck); the two arguments are not initialised.
it looks like you want to pass the outputs of checkOne and checkTwo as the arguments
public static void main(String[] args) {
greeting();
questiona();
questionb();
username();
password();
boolean usernamecheck = checkOne(validusername, inputusername);
boolean passwordcheck = checkTwo(validpassword, inputpassword);
checkFinal(usernamecheck, passwordcheck);
}
From the other answers, you should get an idea of what you need to do to fix your error. One other way is to shorten your method to call the checkFinal method with the other two methods as parameters so you don't need to create another variable.
checkFinal(checkOne(validusername, inputusername),
checkTwo(validpassword, inputpassword));
A few additional comments about your code:
The method:
public static boolean checkOne(String validusername, String inputusername) {
boolean usernamecheck = false;
if (validusername == inputusername) {
usernamecheck = true;
}
return usernamecheck;
}
can be changed to:
public static boolean checkOne(String validusername, String inputusername) {
boolean usernamecheck = validusername.equals(inputusername);
return usernamecheck;
}
First thing is that you cannot compare two string using ==. Second thing, you don't need to compare boolean == true. When you say if (boolean) it is implied that it means if (boolean == true). Same goes for your other methods as well.
For example:
public static boolean checkFinal(boolean usernamecheck, boolean passwordcheck) {
boolean checkFinal = false;
if (usernamecheck == true && passwordcheck == true) {
checkFinal = true;
} else {
checkFinal = false;
}
return checkFinal;
}
can be written as:
public static boolean checkFinal(boolean usernamecheck, boolean passwordcheck) {
return usernamecheck && passwordcheck;
}
You are not saving the boolean results so that they can be passed to the next step. But you could pass them into checkfinal() like this:
public static void main(String[] args) {
greeting();
inputusername = questiona();
inputpassword = questionb();
/* these 2 are not used and may not be necessary
username();
password();
*/
checkfinal(checkOne(validusername, inputusername),
checkTwo(validpassword, inputpassword));
}
Also, note that you probably should set the global variables with the result of the questiona() and questionb() methods as I did. It will work as you have it but it is a bad habit.
I'm doing an assignment in which I have created an Appliance class that has a timePasses()method within it. This method re-directs some values that need to be stored within another method that is inside of another class. Here is where I am up to on this:
Appliance
public class ElectricCooker extends Cooker {
public int isOn = -1;
public int isOff = 0;
public int incrementTime;
public int varPass = -1;
#Override
public int currentState() {
if (varPass == 0) {
return isOff;
} else {
return isOn;
}
}
#Override
public void useTime(int defaultTime) {
defaultTime = 15;
incrementTime = 4;
}
#Override
public void timePasses() {
if (varPass == isOff) {
varPass = 0;
} else {
ElectricMeter.getInstance().incrementConsumed(electricityUse);
GasMeter.getInstance().incrementConsumed(gasUse);
WaterMeter.getInstance().incrementConsumed(waterUse);
}
}
ElectricCooker(int electricityUse, int gasUse, int waterUse, int timeOn) {
super(electricityUse, gasUse, waterUse, timeOn);
this.electricityUse = 5 * incrementTime;
this.gasUse = 0 * incrementTime;
this.waterUse = 0 * incrementTime;
this.timeOn = 15 * incrementTime;
}
}
Meter
public class ElectricMeter {
ElectricMeter() {
}
private static ElectricMeter instance = new ElectricMeter();
public static ElectricMeter getInstance() {
return instance;
}
public void incrementConsumed(int value) {
System.out.println(value);
}
public int incrementGenerated() {
}
public boolean canGenerate() {
}
public String getConsumed() {
}
public String getGenerated() {
}
}
Main method
public class MainCoursework {
public static void main(String[] args) {
ElectricMeter a = new ElectricMeter();
a.incrementConsumed(//what goes here?);
}
}
So the value from timePasses()has been redirected into an ElectricMeter instance but now I need to return that value to the increentConsumed() method in the meter class and I'm stuck on how to do this. Since the value of electricityConsumed is 20, the output should be 20. But instead I have to pass a parameter into a.incrementConsumed(//pass parameter here) and what ever is passed gets printed out onto the screen instead of the 20 from electrictyUse. Any help on how to do this is appreciated, thanks.
Actually, the incrementConsumed method is indeed implemented as you described:
public void incrementConsumed(int value)
{
System.out.println(value);
}
A method called incrementXXX shouldn't really output anything, should it? It should increment a variable/field:
private int electricityUsed = 0;
public void incrementConsumed(int value)
{
electricityUsed += value;
}
You should declare another method that returns electricityUsed:
public int getElectricityUsed() {
return electricityUsed;
}
Now let's fix your main method.
In your main method, you didn't even create anything that consumes electricity! How can the electric meter incrementConsumed? So remove everything from the main method and create a cooker:
// your constructor looks weird. So I passed in some random arguments..
ElectricCooker cooker = new ElectricCooker(20, 0, 0, 60);
Now call timePasses to simulate that some time passed:
cooker.timePasses();
And print the electricity used:
System.out.println(ElectricMeter.getInstance().getElectricityUsed());
you need to create an instance variable in ElectricMeter and update that value on say incrementConsumed. When you want to print that use accessor of this variable.
public class Electric {
public static void main(String[] args) {
ElectricCooker cooker = new ElectricCooker(1,2,3,4);
//opertion on cooker
//ignoring best way for singleton creation
int electricityUse = ElectricMeter.getInstance().getElectricityUse();
System.out.println(electricityUse);
}
}
class ElectricCooker // extends Cooker
{
public int isOn = -1;
public int isOff = 0;
public int incrementTime;
public int varPass = -1;
public int electricityUse = -1;
public int currentState() {
if (varPass == 0)
return isOff;
else {
return isOn;
}
}
public void useTime(int defaultTime) {
defaultTime = 15;
incrementTime = 4;
}
public void timePasses() {
if (varPass == isOff)
varPass = 0;
else {
ElectricMeter.getInstance().incrementConsumed(electricityUse);
}
}
ElectricCooker(int electricityUse, int gasUse, int waterUse, int timeOn) {
this.electricityUse = 5 * incrementTime;
}
}
class ElectricMeter {
public int electricityUse = -1;
private static ElectricMeter instance = new ElectricMeter();
public static ElectricMeter getInstance() {
return instance;
}
public void incrementConsumed(int value) {
this.electricityUse = value;
}
public int getElectricityUse() {
return electricityUse;
}
}
In ElectricMeter, some operations don't perform what they should.
ElectricMeter.getInstance().incrementConsumed(electricityUse);
should increment something but it writes only in the output:
public void incrementConsumed(int value){
System.out.println(value);
}
You should write it rather :
public void incrementConsumed(int value){
consumed+=value;
}
and add a private int consumed field in ElectricMeter class to store the actual consumed.
And your getConsumed() which has a empty implementation :
public String getConsumed(){
}
should simply return the consumed field and you should return a int value and not a String.
public int getConsumed() {
return consumed;
}
In this way, you can do :
public static void main(String[] args){
ElectricMeter.getInstance().incrementConsumed(20);
int consumed = ElectricMeter.getInstance().getConsumed();
}
Is there any alternative way to identify instance of multidimensional object without hardcode on it?
//source
import java.util.LinkedList;
import java.util.List;
public class Test {
public static <T> boolean isPrimitiveWrapper(T p_obj) throws Exception {
if (Number.class.isInstance(p_obj) || Number[].class.isInstance(p_obj)) {
return true;
} else if (Boolean.class.isInstance(p_obj) || Boolean[].class.isInstance(p_obj)) {
return true;
} else if (Character.class.isInstance(p_obj) || Character[].class.isInstance(p_obj)) {
return true;
}
return false;
}
public static void main(String[] args) throws Exception {
Integer[][][] a = {{{0}}, {{1}}, {{0}}};
println(isPrimitiveWrapper(a));
println(isPrimitiveWrapper(a[0]));
println(isPrimitiveWrapper(a[0][0]));
println(isPrimitiveWrapper(a[0][0][0]));
}
public static <T> void println(T p_t) {
System.out.println(p_t);
}
}
//Actual Result
false
false
true
true
//Expected Result
true
true
true
true
Based on the example above, we have no problem to deal with non-array & single dimension array object, but it is fail to identify multidimensional array object.
It is too ugly to hardcode the number of dimension.
There's no standard way to determine, if the class itself is wrapper for primitive type or not, so, you can do something like this:
private static final Set <Class <?>> primitiveWrappers;
static {
Set <Class <?>> tmp = new HashSet<>();
tmp.add (Integer.class);
tmp.add (Boolean.class);
tmp.add (Character.class);
tmp.add (Long.class);
tmp.add (Double.class);
tmp.add (Float.class);
// ... have I forgotten smth?
primitiveWrappers = Collections.unmodifiableSet(tmp);
}
private static boolean isPrimitiveWrapperOrArrayOf(Object o) {
if (o.getClass().isArray())
return isPrimitiveWrapperOrArrayOf(o.getClass().getComponentType());
else
return primitiveWrappers.contains(o.getClass());
}
When you run isPrimitiveWrapperOrArrayOf, the class is being checked if it's array, if it is, we'll check it's component type (for example, that would be Integer[] for Integer[][]) in the same function isPrimitiveWrapperOrArrayOf, so this way we'll come to just SomeClass, which will be checked if it's contained inside hardcoded primitiveWrappers
By the way, you may take a look at Commons Lang, ClassUtils.wrapperToPrimitive may solve your problem.
Try this approach. I guess that's what you want.
But this code looks like some sort of a hack anyway
(which is not necessarily bad).
private static boolean isPrimitiveWrapper(Object obj){
if (obj == null) {
return false;
} else {
String cls = obj.getClass().getCanonicalName();
return "java.lang.Integer".equals(cls) ||
cls.startsWith("java.lang.Integer[]");
}
}
Here is another hack. Both codes should work OK though.
private static boolean isPrimitiveWrapper(Object obj){
if (obj == null) {
return false;
} else {
String cls = obj.getClass().getName();
cls = cls.replaceAll(";", "");
return cls.matches("\\[*L?java\\.lang\\.Integer");
}
}
public class Test {
public static <T> boolean isPrimitiveWrapper(T p_obj) throws Exception {
return isPrimitiveWrapper(p_obj.getClass());
}
public static boolean isPrimitiveWrapper(Class p_obj) throws Exception {
if (Number.class.isAssignableFrom(p_obj)) {
return true;
} else if (Boolean.class.isAssignableFrom(p_obj)) {
return true;
} else if (Character.class.isAssignableFrom(p_obj)) {
return true;
} else if (p_obj.isArray()) {
//To handle multi dimension array
while (p_obj.isArray()) {
p_obj = p_obj.getComponentType();
}
return isPrimitiveWrapper(p_obj);
}
return false;
}
public static boolean isPrimitiveWrapper(boolean p_obj) {
return false;
}
public static boolean isPrimitiveWrapper(byte p_obj) {
return false;
}
public static boolean isPrimitiveWrapper(short p_obj) {
return false;
}
public static boolean isPrimitiveWrapper(float p_obj) {
return false;
}
public static boolean isPrimitiveWrapper(int p_obj) {
return false;
}
public static boolean isPrimitiveWrapper(long p_obj) {
return false;
}
public static boolean isPrimitiveWrapper(char p_obj) {
return false;
}
public static boolean isPrimitiveWrapper(double p_obj) {
return false;
}
public static void main(String[] args) throws Exception {
Integer[][][] a = {{{0}}, {{1}}, {{0}}};
int[][][] b = {{{0}}, {{1}}, {{0}}};
println(isPrimitiveWrapper(a));
println(isPrimitiveWrapper(a[0]));
println(isPrimitiveWrapper(a[0][0]));
println(isPrimitiveWrapper(a[0][0][0]));
println(isPrimitiveWrapper(b));
println(isPrimitiveWrapper(b[0]));
println(isPrimitiveWrapper(b[0][0]));
println(isPrimitiveWrapper(b[0][0][0]));
}
public static <T> void println(T p_t) {
System.out.println(p_t);
}
}