File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help on a program" Watch "Help on a program" New topic

Help on a program

Ankit Up

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: 15094

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 8 API documentation
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10828

"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

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

Joined: Oct 27, 2005
Posts: 20279

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.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: Help on a program
It's not a secret anymore!