haraprasad mohapatra

Greenhorn
+ Follow
since Apr 15, 2016
Merit badge: grant badges
For More
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
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by haraprasad mohapatra

When we call the method at line 15,arr got a new object and referenced to that new object

so i thought it would show the referene value
7 years ago


output:
3
null
7 years ago



//getting arrayindexoutofbound exception
7 years ago
int i[]={10,20,3,2,4};
int j[]={5,2,15,16,18};

need a new array which will be having elements based on if 'array i' will be compared to 'array j'

Ex:
10 will be compared against 'array j'and and so on ,Only unmatched elements index will be the elements of new array
for 10,20,3,4 will be unmatched so their indexes will be printing into another array

output :
{0 1 2 4}

please help me solve this
7 years ago
yeah but here the ! operator is used in the for loop for break which i was not sure of

so where can i get this kind of code any book or tutorial ???

Please give me the reference (any books,links or tutorial )as i am starting out on java it will be really helpful
7 years ago
yes,that is the problem

inside the for loop how that is actually behaving??

!found what is the significance of this and how its substituting the 'If' statement
7 years ago
public class ArrayNumberCheck
{
private static boolean checkInArray(int checkNum, int[] myArray)
{

boolean found = false;

for (int i = 0; !found && (i < myArray.length); i++) // how its behaving ?
{

found = (myArray[i] == checkNum);
}

return found;
}


public static void main(String[] args)
{
int[] arr = {10,5,15,20,25,200};
int checkNum = 2;

boolean valid = ArrayNumberCheck.checkInArray(checkNum,arr);

if (valid)
{

System.out.print("Value in Array");

}

else

{

System.out.print("Value Not In Array");

}


//System.out.print("Number exists in array");
}
}
7 years ago
But i searched for the answer and dint get any where else .

As i am a beginner where can i get this rules like class structure and static rules etc

please guide me
7 years ago
Please help me understand this why this is not compiled??

Why re-initializing the static variable in separate line is invalid??

public class Test {

static int a;
a =10; //why its invalid

public static void main(String[] arg){
System.out.print(a);
}
}


compilation error: identifier expected why initializing a=10; is not valid whereas static int a=10; is working fine


7 years ago