Two Laptop Bag*
The moose likes Beginning Java and the fly likes Help on a program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help on a program" Watch "Help on a program" New topic
Author

Help on a program

Ankit Up
Greenhorn

Joined: Jun 13, 2009
Posts: 4
Write a program with two constant values, one with alternating binary ones and zeroes, with a zero in the least-significant digit, and the second, also alternating, with a one in the least-significant digit (hint: It’s easiest to use hexadecimal constants for this). Take these two values and combine them in all possible ways using the bitwise operators, and display the results using Integer.toBinaryString( ).

Repeat Exercise using the ternary operator and a bitwise test to display the ones and zeroes, instead of Integer.toBinaryString( ).

This is a question from TIJ4
I have done the first exercise but unable to do second.I cann't understand it.I couldn't think of anything about it.
Please explain something about the question and how to proceed.
I am new to java.Your help will be appreciated.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Welcome to JavaRanch.

So, what exactly do you not understand about it? Do you know what the ternary operator is? If not, did you try to Google it?


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10171
    
    8

"Ankit Up"
Please check your private messages for an important administrative matter.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
geetha garlapad
Greenhorn

Joined: Jun 18, 2009
Posts: 1
hi,how to print * symbol in diamond shape
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19654
    
  18

geetha garlapad wrote:hi,how to print * symbol in diamond shape

Please don't hijack this thread. You should create a new thread instead.

In this case however, I would do a search first. This question has been asked before, either here or in the intermediate forum.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Help on a program
 
Similar Threads
does Double.toString() always return exact value?
Binary representation of an int
Help on a program
java BigNumber 2
-4 >> -3