Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Inner Loop

 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good morning to all,
Any one can help me?How is it processing the loop?

According to me answer is 00011011

But after the compilation i got the result 0001
 
Ranch Hand
Posts: 99
Mac Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you think the answer will be 00011011 ?

In this example the first loop will execute 2 times for i = 0 and i = 1
The second loop will execute 2 times too, for j = 0 and j = 1
Which means the

will execute 2*2 = 4 times for both loop.

Thats why the output is 0001.
 
author
Posts: 23928
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Why do you think the answer will be 00011011 ?



It took me a while too -- but I think the original poster thinks that the "&" operator somehow puts two bits together... meaning 1 & 1 ==> 11.

Henry
 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am surprised with "&"
what does it actually do?
just like "*" in this case?
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am too a bit confused with the Sysout(i&j) what does the "&" signify here? Can anyone please clarify?
 
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy!

You are talking about the bitwise logical AND.
This is expressed by & in Java.



Yours,
Bu.
 
Abdullah Mamun
Ranch Hand
Posts: 99
Mac Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

It took me a while too -- but I think the original poster thinks that the "&" operator somehow puts two bits together... meaning 1 & 1 ==> 11.



Thanks Henry, may be this could be the case.
But it would be better if we could know the poster's thought.
 
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

Although bit manipulation is valuable to know, it's mentioned in K&B that there won't be any questions on the exam for this topic.

However, beware of short circuit code questions on the exam that could be misleading.

Just an fyi...
Aloha,
Doug
 
rex tony
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Dude Burkhard Hassel
Really i got it.
Thanks a lot
rex
 
Remember to always leap before you look. But always take the time to smell the tiny ads:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic