Loading...

Facebook Launched Facebook Messenger for Windows PC

Friday, December 30, 2011 // by Saurabh // Labels: , // No comments:

News Facebook has released Facebook Messenger for Windows platform. To pull more visitors and to give more comfortable to existing windows users, facebook has developed an application for windows platform to let people chat with their facebook contacts anytime. This is a software that works just like Google Talk, MSN Messenger or any other application you use for chatting with your friends online.




This is really a nice move by Facebook to bring more active users online count and to let the messenger service used by many. Facebook messenger for PC also gives you notifications to stay updated on whats happening in your facebook profile and with friends as well.


Facebook Messenger for PC
  • Chat and message with your friends on Facebook
  • See the latest updates from your friends in ticker
  • Get quick notifications about what’s going on
Facebook Chat application is available for Blackberry, Android and iPhone. Facebook addicts should be very careful before using this application, as it will increase the time they stay at facebook literally. People across the world started to search for ways to get rid off facebook addiction and this chat application can cause big damage to their plans if they try out this software  You may now proceed download the facebook messenger for windows here.
Thanks for reading and please do share this post on Facebook to let your friends also know about it.

  • Facebook Messenger for PC || Via Facebook

Microsoft details its Windows Live ID integration in Windows 8

Tuesday, December 27, 2011 // by Saurabh // Labels: , , // No comments:


Microsoft detailed its Windows Live ID integration in Windows 8


The software giant is planning to offer optional Windows Live sign-in for user accounts as part of Windows 8. The developer preview build of Windows 8 offers some parts of the integration but Microsoft plans to include the following in Windows 8:


Associate the most commonly used Windows settings with your user account. Saved settings are available on each Windows 8 PC you sign in to
Windows 8 Metro style app settings and last-used state persist across all Windows 8 PCs linked PCs
Website and application login credentials are automatically synced across Windows 8 linked PCs
Automatically sign in to apps and services that use Windows Live ID for authentication
Windows 8 users can choose which settings they would live to sync across their PCs. Settings such as the lock screen picture you’ve chosen or Windows desktop wallpaper, account user tile, browser favourites and explorer settings will sync across all Windows Live ID linked PCs. “They are kept in sync and come down to each machine you use as they are changed or updated,” explained Katie Frigon of Microsoft’s you-centered experience team in a blog post on Monday.


“We’ve recommended a default behavior that assumes you want to roam settings that are used most often to personalize and customize the way you use your PC,” says Frigon. “You maintain control of your data when work and personal start to mix.” Microsoft asks Windows 8 users which type of data they want to sync if they choose to link a Windows Live ID to a Windows Domain account. “You can decide if things like your web history, favorites, or credentials should sync to your work machine, or if you’d prefer to keep those or anything else that is synced only on your personal machines,” explains Frigon.


IT administrators can also control what a user decides to sync to a work PC through group policy. “We have provided control to IT administrators to decide if a worker can link their domain account to an ID, and if the admin allows that link, what types of data the worker is allowed to sync,” says Frigon. Microsoft also separates the Windows domain credentials so they never get synced to the cloud.


Microsoft is safe guarding the data and privacy of Windows 8 users by requiring a strong password and a secondary proof of identity. The secondary proof will enable users to create a trust between PCs that they own and Windows Live. “Collecting the secondary proof of your identity also helps make account recovery easier and more secure,” explains Frigon. Microsoft has taken extra steps to ensure data is protected too. The company will not roam data over WWAN by default and all user data is encrypted on the client before it’s sent to Microsoft’s cloud servers. All data is then transmitted using SSL/TLS. “The most sensitive information, like your credential information, is encrypted once based on your password and then encrypted again as it is sent across the Internet,” explains Frigon. Windows 8 users will be able to establish a secure PC by providing the extra proof of identity. The secondary proof can be setup using a mobile phone via SMS or a secondary email address.


Microsoft believes the new settings will make the Windows 8 experience more personal and easier to setup across multiple devices. “We look forward to hearing about how you are enjoying the feature and to receiving your feedback,” says Frigon.



Microsoft reveals its own password store for Windows 8

// by Saurabh // Labels: , , , // No comments:



Microsoft revealed that it’s planning a password store for Windows 8, negating the requirement for applications such as 1Password and LastPass.


Microsoft has tried a number of methods over the years to improve password management in Windows. The latest operating system, due to make its debut next year, will feature two password stores that keep web credentials and Windows credentials safe. Windows 8 will automatically store and retrieve passwords for websites and applications. Application and website developers can build support for storing passwords or disable the functionality. “Anyone building a Metro style app can use a direct API to securely store and retrieve credentials for that app,” explained Microsoft’s Dustin Ingalls in a blog post detailing the new features.


Microsoft is also planning to link the saved passwords into its cloud sync support. Windows 8 will feature the ability to link Windows Live IDs and Windows accounts together. Saved credentials will automatically sync between trusted Windows 8 PCs that belong to a particular Windows Live ID. “When you store credentials in conjunction with signing in to Windows with your Windows Live ID, Windows enables you to set your password for each account to something that is both complex and unique; since Windows 8 will automatically submit the credential on your behalf, you’ll never need to remember it yourself,” explains Ingalis. Windows 8 users will be able to view their passwords and usernames to websites from the credential manager. Windows 8′s credential manager builds on Apple’s Keychain idea but pushes the implementation further. The cloud sync support for passwords will make it incredibly easy for users of multiple machines to keep their devices fully synced.




The final part of Microsoft’s password improvements for Windows 8 sees the company introduce the ability for the TPM computer chip to act as a virtual smart card. This solution will appeal to business and enterprise customers who regularly have to access banking and commerce sites using a specially assigned smart card. The virtual smart card feature removes the requirement for a physical smart card and takes advantage of the TPM chip inside. “The virtual smart card feature can be used in place of existing smart cards with any application or solution that is smart card compatible,” explains Ingalis. “No server or application-side changes are required.”



Gmail-powered ‘Send a Call from Santa’ Offers Personalized Phone Calls to Kids and Coworkers

Friday, December 23, 2011 // by Saurabh // Labels: , // No comments:


If your kids are expecting a visit from Santa you can answer a few questions and have Google call your child and leave a personalized message.
After starting the webapp you can leave your child's name, gender, state, what type of gift the child really wants, and your own name and relationship to the child. There are also joke options should you want Santa to call your coworkers or friends. You can listen to a sample call here to get the idea.


Webapps should be about making our lives easier, and since many parents are having to do their best to placate kids until next weekend, this webapp from Google might help you remind your kids to be patient. Happy holidays!
Send a Call from Santa || via Gmail

Better Explorer Brings Ribbon Style Explorer to Windows 7

Saturday, December 17, 2011 // by Saurabh // Labels: , , // No comments:





Windows & Softwares : If you like the look of Windows 8's new version of Windows Explorer, but don't want to use the developer preview, free app Better Explorer brings some of the perks to your Windows 7 desktop.
Better Explorer attempts to emulate the best features of Windows 8'd Explorer, like the collapsible ribbon UI and the quick access toolbar, while also adding tabs and a bit of extra jumplist options. It's a completely separate program, too, not an add-on for Windows Explorer, which can be kind of a scary endeavor sometimes. The tabs are definitely nice to have, and adding functions like Copy, Paste, or Refresh to the quick access toolbar is just a matter of right-clicking on them.


Better Explorer is still in the alpha stages, and while it's quite usable, it isn't exactly perfect. There doesn't seem to be an obvious keyboard shortcut for opening a new tab, nor is there anything under the File menu. I haven't noticed any big bugs, but just know that it isn't a finished product. Development doesn't seem to fast, either, but it'll certainly hold you over until Windows 8 if you don't want to completely replace your file explorer.


Better Explorer is a free download for Windows 7 and Vista only.


Facebook for Android Updates with New, Very Cool Timeline Interface

Friday, December 16, 2011 // by Saurabh // Labels: , , // No comments:



News Android: Facebook rolled out its new Timeline feature yesterday, and if you've enabled the cool new interface, you can update the Android app to get it on your phone as well.
The new version is mostly an interface update, but if you're using Timeline, you'll definitely want to check it out. You get the cover photo, map thumbnails, and the top-down view of all your posts. You can even swipe through albums right from the Timeline view, which is a really nice touch. The update isn't out for iOS yet, but iOS users can head to m.facebook.com to see the new changes if they so desire. Hit the link to read more.


A Single Text Can Destroy Windows Phone’s Messaging App




News & Articles Microsoft’s range of Windows Phone devices suffer from a denial-of-service attack that allows attackers to disable the messaging functionality on a device.


The flaw works simply by sending an SMS to a Windows Phone user. Windows Phone 7.5 devices will reboot and the messaging hub will not open despite repeat attempts. Attack tests have been done on a range of Windows Phone devices, including HTC’s TITAN and Samsung’s Focus Flash. Some devices were running the 7740 version of Windows Phone 7.5, others were on Mango RTM build 7720. The attack is not device specific and appears to be an issue with the way the Windows Phone messaging hub handles messages. The bug is also triggered if a user sends a Facebook chat message or Windows Live Messenger message to a recipient.


The flaw appears to affect other aspects of the Windows Phone operating system too. If a user has pinned a friend as a live tile on their device and the friend posts a particular message on Facebook then the live tile will update and causes the device to lock up. Thankfully there’s a workaround for the live tile issue, at initial boot up you have a small amount of time to get past the lock screen and into the home screen to remove the pinned live tile before it flips over and locks the device.


Both Apple and Google have suffered from SMS bugs with their iOS and Android devices. Security researcher Charlie Miller discovered a flaw in the iOS 3.0 software that allowed attackers complete control over an iPhone at the time. Android-based phones also suffered in the SMS attack, but attackers could only knock a phone offline rather than gain full access. The attack described in this article does not appear to be security related. It appears, from our limited testing, that the bug is related to the way Windows Phone handles messages.


See the Video below by a Win Rumors reader:




The vid, narrated by a WinRumors reader who discovered the flaw, shows how one message will force a Mango device to reset, at which point the messaging app will no longer launch. The messaging app, being arguably the greatest and certainly one of the most used features on the phone, is not something you want deactivated. WinRumors says they're working with Microsoft to get the bug reported and patched. Phew.

  •  A Single Text Can Destroy Windows Phone’s Messaging App || Via Win Rumors

Got Something to Say? Shoot out in Comments Below.

Tutorial: How to Create a Facebook Application to Get an App ID for your Website or Blog

Thursday, December 15, 2011 // by Saurabh // Labels: , , // No comments:

Developers Facebook has updated the way you integrate your website into its Open Graph, and how you set up Insights, Facebook’s analytics tool, to see how users are interacting with the social plugins — primarily the Like Button and the Comments Box — you’ve added to your website’s pages.
In this tutorial, I will describe the steps necessary to integrate your website with Facebook, by getting an App ID for your site and adding the Open Graph meta tags to your site’s pages.
Setting up your Website as a Facebook Application

First, you must set up your website as a Facebook “application” which provides you with an Application ID you use to integrate your website into Facebook’s Open Graph, so you can add Facebook’s Social Plugins to your site.

Installing the Facebook Developer Application
The first step in creating an application in Facebok is to install the Facebook Developer application.
To do that, log in to Facebook and then visit the URL http://facebook.com/developers.
If this is the first time you’ve installed the Developer Application, you will see the Request for Permission dialog show below:


Click the Allow button to proceed.

Creating the Facebook Application for your Website
Now that you have the Developer App installed, click on the Create New App button.


Give you application an “App Display Name” (the name displayed to users).
For purposes of this tutorial, you don’t need to have a “Namespace”.
Click the “I agree to Facebook Platform Policies” box; then click the Continue button.


On the next screen, enter the security phrase and then click Submit.


There are a lot of options you can tweak related to your application. In this post, we are going to focus on the basics needed to get your website set up with a Facebook App ID.

The Settings Tab
This is where you do the basic set up for your app.
For the purposes of this tutorial, you need to concern yourself only with the Basic Settings which will suffice for setting up your website as an application to get an App ID.


OK, there’s your App ID! You’re almost there. Your App ID is the value you’ll be using to integrate your website with Facebook’s APIs so you can add the Social Plugins (Like Button, Send Button, Comments Box, etc.).
For the purposes of this tutorial, you won’t need your “App Secret” value.
Second, notice the “edit icon” below the App Secret. You don’t need to add an icon. If your website has a favicon, it will be displayed next to your site’s URL in Facebook Insights.
Basic info:
  • App Display Name: Make this the same as the original value you provided;
  • App Namespace: Leave blank;
  • Contact Email: Where you want Facebook to send emails regarding your app;
  • App Domain: I just put “mydomain.com” where “mydomain.com” is your website’s domain URL (TLD);
  • Category: Select a category from the pulldown list (optional).
Cloud services
This is not applicable for a “website” Facebook application.
Select how your App integrates with Facebook
It’s here where you tell Facebook that your App is a website or blog.


Once you’ve filled in your website or blog URL, click the “Save Changes” button and you’re done!
Your website is now an “object” in Facebook’s Open Graph, with its own App ID.

How to Set Up Your Website or Blog with Facebook Insights for Domains


Developers In this article, I’ll show you how to access Facebook Insights for Domains to learn how people are interacting with your website’s or blog’s content.
Once you have added Facebook Social Plugins to your website, such as the Like Button or Comments Box, you’ll want to know how users are interacting with these Social Plugins.
Facebook Insights for Domains, according to Facebook:


… offers a consolidated view of key metrics for any website, even those that have not implemented Facebook Platform. For example, if a user links to your site in their Facebook status message, that data is included in the analytics for your domain. You can access sharing metrics and demographic information per domain and per URL so you can optimize your content for sharing and better tailor your content to your audience.


Facebook has been continually improving Insights over the past year and you will definitely want access to the data it offers.
Facebook Insights for Domains — Prerequisites


To use Facebook Insights for Domains, you must first:
  • Create a Facebook application associated with your website or blog, so that your website or blog becomes an “object” in the Open Graph.
  • Add the appropriate Open Graph meta tags to your Web page.
  • Add Like Buttons or other Social Plugins to your website.
Here are several tutorials to help you do this:


Step 1: Claim your Domain


To see Insights for your website or blog, you must claim your domain by associating it with a Facebook page or app that you manage, or with your Facebook user account.
Here is the drill:
Log in to your Facebook account.
Go to the Facebook Insights page. Because you are logged in, you will see the Websites and Apps for which you already have Insights.
To add a website or blog, click the green “Insights for your Domain” button in the top right corner.




You will see this popup dialog:




Domain: Enter the domain for which you want to gain access to Insights. (You don’t need “http://www.”, just “your-domain.com”.)
Link With: In the pulldown list, besides your Facebook account, are all the websites and Fan Pages for which you’re indicated as an owner of the Web page (in the meta tags) or admin of the Fan Page. You have 3 options here:
(You): If you want to be the only one with access to this domain’s Insights, select this option;
Website, Fan Page or Facebook App: If you want to have more than one Facebook account have access to the domain’s Insights, select from the pulldown list of Fan Pages or Facebook Apps you admin, or websites for which you’ve created a Facebook App (See this tutorial on how to create a Facebook App) and are an admin. Whether you choose an App or a Facebook Page, all admins of the Facebook App or Fan Page will have access to the Insights for the domain you’re adding;
The <meta property="" content="" /> tag generated after you make your “Link With” selection should be present in the <head> tags of any Web page for which you want Insights.
Depending on what you choose to link with, the meta tag content will be either your Facebook User ID, the Fan Page ID, or the website App ID.
If you get this error dialog after clicking the “Get Insights” button…




it’s because you haven’t added the appropriate Facebook meta tags to the home page of your website to prove ownership of the domain.
Make sure you paste the generated <meta property="" content="" /> tag into the <head> of your home page, as well as any other pages you want to appear in Insights.
Now you can start using Insights!
If you get into any trouble just drop your issues in comments.

Picasa 3.9 Is Out: Now with Google+ Sharing and Tagging

Wednesday, December 14, 2011 // by Saurabh // Labels: , , // No comments:

On December 8, 2011, A New Update to Picasa 3.9 was Announced Which Includes Google+ sharing and tagging

Share with people in your Google+ circles: 
Picasa 3.9 makes it easy to share the right photos with the right people with just a few clicks. To share an album, just click on the green “Share on Google+” button and add the specific circles you want to share your photos with.

Tag people in your circles:  When you click a photo to tag a friend, the dropdown menu now includes people in your Google+ circles in addition to your Gmail contacts. If you tag friends from Google+, Picasa will automatically suggest that you share your pictures with them when you upload your album.

Upload all your pictures for free:  Picasa 3.9 offers two simple upload options for Google+ users, original size and best for web sharing. When you select the “Best for web sharing”  option, you can upload any number of pictures for free! What’s more, these pictures are uploaded at high resolutions of up to 2048 px.

And That's not just all..

  • 24 new photo editing effects 


  • Side by side photo comparison 


  • Simplified tray interface: Less commonly used tray icons (such as BlogThis!, Collage, Movie, Shop)  are hidden by default (you can always add them back).  

Microsoft Tag Announces One-Stop-Shop for Marketers: Tag, QR and NFC




News & Article Microsoft Tag came out of beta about 18 months ago, and since then mobile barcodes have become more mainstream and adoption is growing at an impressive clip. Marketers are just beginning to harness the power of Tag for all its qualities: a high-quality reader, Tag customization, advanced analytics, extensibility via Microsoft's SDK and more.


And based on the customer feedbacks, it became very useful application in the field of Digitization and NFC




To help simplify the growing fragmentation currently taking place in the barcode/reader market, today Microsoft Tag is providing support for the two commonly used 2D barcode formats (Tag and QR Codes) and for Near Field Communications (NFC) capabilities. With this extension, brands have the freedom to choose the format most appropriate for their campaigns and give consumers the ease of one reader to use.


Microsoft Tag is proud to extend its mobile marketing solution to include several recognition technologies, giving the flexible options to users for deciding how to engage with the audience. and Its the only solution in market that can create and scan Tag barcodes, QR Codes, and NFC touchpoints, all with a single creation tool and mobile app.


Each of the recognition technologies can be used alone or paired together to maximize the engagement. All can be created within minutes using Tag Manager and our reporting gives you the insight you need to accurately measure your campaign’s performance. And just like Tag barcodes, our QR Codes and NFC URLs can be updated whenever needed in Tag Manager so you can keep your materials fresh.


Isn't that Cool?



features_list_item_img

Raise Curiosity

Tag barcodes continue to deliver the great experience you’ve become accustomed to, providing a customizable look and feel, a smaller size, and tremendous scanning reliability. Tag barcodes also offer Real Time Location and Device ID to let you truly personalize your campaigns.
features_list_item_img

Grab Their Attention

We’ve expanded our 2D barcode offering to include the traditional QR Code format. QR Codes created using Tag Manager will have the standard look and feel of other QR generators, but also offer the flexibility that you enjoy with Tag barcodes, including updating content on the fly and advanced reporting. QR Codes created with Tag Manager and scanned using the Tag app can also deliver location and device aware experiences. QR Codes created in Tag Manager can be scanned by third-party apps too, so you won’t lose any connection with your customers.
features_list_item_img

Blend in Beautifully

Near Field Communication (NFC) is the latest and greatest in mobile technology. While still in the early stages, several Android devices come NFC-enabled, providing you a unique way to engage with your customers. They simply tap their device to the touchpoint to launch their mobile experience and away they go! You can create NFC URLs using Tag Manager and then provide those to third-party NFC vendors to create your touchpoints. NFC URLs can be updated at any time, saving you valuable time and money in keeping your touchpoints relevant. Use our reporting to measure every ‘tap’ and see where and how often people are engaging with your content.
  • Microsoft Tag Announces One-Stop-Shop for Marketers: Tag, QR and NFC || via Microsoft Tag Blog

Java Control Statement

// by Saurabh // Labels: , // No comments:


Java Control statements control the order of execution in a java program, based on data values and conditional logic. There are three main categories of control flow statements;
  • Selection statements: if, if-else and switch.
  • Iteration statements: while, do-while and for.
  • Transfer statements: break, continue, return, try-catch-finally and assert.
We use control statements when we want to change the default sequential order of execution


Selection Statements


The If Statement


The if statement executes a block of code only if the specified expression is true. If the value is false, then the if block is skipped and execution continues with the rest of the program. You can either have a single statement or a block of code within an if statement. Note that the conditional expression must be a Boolean expression.


The simple if statement has the following syntax:


if (<conditional expression>)
{
        <statement action>;
}


Below is an example that demonstrates conditional execution based on if statement condition.


public class IfStatementDemo {

 public static void main(String[] args) {


  int a = 10, b = 20;
  if (a > b)
   System.out.println("a > b");
  if (a < b)
   System.out.println("b > a");
 }
}


Output: b > a



The If-else Statement


The if-else statement is an extension of the if statement. If the statements in the if statement fails, the statements in the else block are executed. You can either have a single statement or a block of code within if-else blocks. Note that the conditional expression must be a Boolean expression.


The if-else statement has the following syntax:


if (<conditional expression>)
{
        <statement action>;
}
else
{
        <statement action>;
}


Below is an example that demonstrates conditional execution based on if else statement condition.

public class IfElseStatementDemo
{
 public static void main(String[] args)
 {
  int a = 10, b = 20;
  if (a > b)
  {
   System.out.println("a > b");
  }
  else
  {
   System.out.println("b > a");
  }
 }
}


Output: b > a


Nesting of if-else Statements


When a series of decisions are involved, we may have to use more than one if-else statement in nested form. The general syntax for nested if else is as follows:



if(<Conditional Statements>)
{
if(<Conditional Statement>)
{
<Statement>;
}
else
{
<Statement>;
}
}
else
{
<Statement>;
}

Below is an example that demonstrates conditional execution based on if else statement condition.


public class IfElseStatementDemo
{
 public static void main(String[] args)
 {
    int a = 10, b = 20, c = 30;
    if (a > b)
    {
   if (a > c)
   {
       System.out.println("a is greater");
   }
  }
  else
  {
   if(b > c)
   {
    System.out.println("b is greater");
   }
   else
   {
    System.out.println("c is greater");
   }
  }
 }
}


Output: c is greater


The Ladder if-else Statements


There is another way of putting if-else together when multi-path decisions are involved. A multipath decision is a chain of its in which the statement associated with each else is an if. It takes the following general form:



if(Condition)
{
<Statement>;
}
else if(Condition)
{
<statement>;
}
else if(Condition)
{
<Statement>;
}
else
{
<Statement>;
}
<Statement x>;


The Conditions are evaluated from top to bottom, as soon as the True condition is found, the Statement associated with it is executed and the control is transferred to the <Statement x>; (Skipping the rest of the Ladder) When all the condition becomes false, then the final else containing the default-statement will be executed.


Example:




class LadderIfElse
{
 public static void main(String arg[])
 {
  int marks = 85;
  char grade;
  if (marks >=90)
  {
   grade = 'A' ;
  }
  else if (marks >= 70)
  {
   grade = 'B' ;
  }
  else if (marks >= 50)
  {
   grade = 'C';
  }
  else
  {
   grade = 'F'
  }
  System.out.print("Your Grade: " +grade);
 }
}


The Ladder If-else gave birth to Switch Case Statement, Which is based on the working of Ladder if-else.



Switch Case Statement


The switch case statement, also called a case statement is a multi-way branch with several choices. A switch is easier to implement than a series of if/else statements. The switch statement begins with a keyword, followed by an expression that equates to a no long integral value. Following the controlling expression is a code block that contains zero or more labeled cases. Each label must equate to an integer constant and each must be unique. When the switch statement executes, it compares the value of the controlling expression to the values of each case label. The program will select the value of the case label that equals the value of the controlling expression and branch down that path to the end of the code block. If none of the case label values match, then none of the codes within the switch statement code block will be executed. Java includes a default label to use in cases where there are no matches. We can have a nested switch within a case block of an outer switch.


Its general form is as follows:


switch(<non-long integral expression>)
{
case label1: <statement1>
case label2: <statement2>

case labeln: <statementn>
default: <statement>
} // end switch


When executing a switch statement, the program falls through to the next case. Therefore, if you want to exit in the middle of the switch statement code block, you must insert a break statement, which causes the program to continue executing after the current code block.


Below is a java example that demonstrates conditional execution based on nested if else statement condition to find the greatest of 3 numbers.

public class SwitchCaseStatementDemo
{
 public static void main(String[] args)
 {
  int a = 10, b = 20, c = 30;
  int status = -1;
  if(a > b && a > c)
  {
   status = 1;
  }
  else if (b > c)
  {
   status = 2;
  }
  else
  {
   status = 3;
  }
  switch(status)
  {
   case 1:
   System.out.println("a is the greatest");
   break;
   case 2:
   System.out.println("b is the greatest");
   break;
   case 3:
   System.out.println("c is the greatest");
   break;
   default:
   System.out.println("Cannot be determined");
  }
 }
}

Output: c is the greatest


Iteration Statements


While Statement


The while statement is a looping construct control statement that executes a block of code while a condition is true. You can either have a single statement or a block of code within the while loop. The loop will never be executed if the testing expression evaluates to false. The loop condition must be a boolean expression.


The syntax of the while loop is


while (<loop condition>)
{
<statements>;
}


Below is an example that demonstrates the looping construct namely while loop used to print numbers from 1 to 10.


public class WhileLoopDemo
{
 public static void main(String[] args)
 {
  int count = 1;
  System.out.println("Printing Numbers from 1 to 10");
  while (count <= 10)
  {
   System.out.print(count++);
   System.out.print(",");
   if(count==10)
   {
    System.out.println("\b"); //backspace
   }
  }
 }
}


Output:
Printing Numbers from 1 to 10
1,2,3,4,5,6,7,8,9,10


Do-while Loop Statement


The do-while loop is similar to the while loop, except that the test is performed at the end of the loop instead of at the beginning. This ensures that the loop will be executed at least once. A do-while loop begins with the keyword do, followed by the statements that make up the body of the loop. Finally, the keyword while and the test expression completes the do-while loop. When the loop condition becomes false, the loop is terminated and execution continues with the statement immediately following the loop. You can either have a single statement or a block of code within the do-while loop.


The syntax of the do-while loop is:


do
{
<loop body>
}
while (<loop condition>);


Below is an example that demonstrates the looping construct namely do-while loop used to print numbers from 1 to 10.


public class DoWhileLoopDemo
{
 public static void main(String[] args)
 {
  int count = 1;
  System.out.println("Printing Numbers from 1 to 10");
  do
  {
   System.out.print(count++);
   System.out.print(",");
   if(count==10)
   {
    System.out.print("\b");
   }
  }
  while (count <= 10);
 }
}


Output:
Printing Numbers from 1 to 10
1,2,3,4,5,6,7,8,9,10



For Loops


The for loop is a looping construct which can execute a set of instructions a specified number of times. It’s a counter controlled loop.


The syntax of the loop is as follows:



for (<initialization>; <loop condition>; <increment expression>)
{
<loop body>;
}


The first part of a for statement is a starting initialization, which executes once before the loop begins. The <initialization> section can also be a comma-separated list of expression statements. The second part of a for statement is a test expression. As long as the expression is true, the loop will continue. If this expression is evaluated as false the first time, the loop will never be executed. The third part of the for statement is the body of the loop. These are the instructions that are repeated each time the program executes the loop. The final part of the for statement is an increment expression that automatically executes after each repetition of the loop body. Typically, this statement changes the value of the counter, which is then tested to see if the loop should continue.
All the sections in the for-header are optional. Any one of them can be left empty, but the two semicolons are mandatory. In particular, leaving out the <loop condition> signifies that the loop condition is true. The (;;) form of for loop is commonly used to construct an infinite loop.


Below is an example that demonstrates the looping construct namely for loop used to print numbers from 1 to 10.


public class ForLoopDemo
{
 public static void main(String[] args)
 {
  System.out.println("Printing Numbers from 1 to 10");
  for (int count = 1; count <= 10; count++)
  {
   System.out.print(count+",");
   if(count==10)
   {
    System.out.println("\b");
   }
  }
 }
}


Output:

Printing Numbers from 1 to 10
1,2,3,4,5,6,7,8,9,10


Transfer Statements


Continue Statement


A continue statement stops the iteration of a loop (while, do or for) and causes execution to resume at the top of the nearest enclosing loop. You use a continue statement when you do not want to execute the remaining statements in the loop, but you do not want to exit the loop itself.


The syntax of the continue statement is


continue; // the unlabeled form
continue <label>; // the labeled form


You can also provide a loop with a label and then use the label in your continue statement. The label name is optional, and is usually only used when you wish to return to the outermost loop in a series of nested loops.


Below is a program to demonstrate the use of continue statement to print Odd Numbers between 1 to 10.


public class ContinueExample
{
 public static void main(String[] args)
 {
  System.out.println("Odd Numbers");
  for (int i = 1; i <= 10; ++i)
  {
   if (i % 2 == 0)
   continue; // Rest of loop body skipped when i is even
   System.out.println(i + " ");
  }
 }
}


Output:
Odd Numbers
1 3 5 7 9



Break Statement


The break statement transfers control out of the enclosing loop ( for, while, do or switch statement). You use a break statement when you want to jump immediately to the statement following the enclosing control structure. You can also provide a loop with a label, and then use the label in your break statement. The label name is optional, and is usually only used when you wish to terminate the outermost loop in a series of nested loops.


The Syntax for break statement is as shown below;


break; // the unlabeled form
break <label>; // the labeled form


Below is a program to demonstrate the use of break statement to print numbers Numbers 1 to 10.


public class BreakExample
{
 public static void main(String[] args)
 {
  System.out.println("Numbers 1 - 10");
  for (int i = 1;; ++i)
  {
   if (i == 11)
   break; // Rest of loop body skipped when i is 11
   System.out.println(i + " ");
  }
 }
}


Output:
Numbers 1 - 10
1 2 3 4 5 6 7 8 9 10

Popular Posts

Advertisement