473,756 Members | 9,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

what is the logic

9 New Member
Expand|Select|Wrap|Line Numbers
  1. public static void main(String[ ] args) {
  2.       int x = 5;
  3.       while (x > 1) { 
  4.           x = x + 1;
  5.           if (x < 3) {
  6.                System.out.println("small x");
  7.           }
  8.       }
  9.  }

the output of the program is smallx but how?
Apr 28 '10 #1
2 1248
Dheeraj Joshi
1,123 Recognized Expert Top Contributor
I will suggest you to put the print statement for x inside the if loop

Expand|Select|Wrap|Line Numbers
  1. public static void main(String[ ] args) {
  2. int x = 5;
  3. while (x > 1) { 
  4. x = x + 1;
  5. if (x < 3) {
  6. System.out.println(x);
  7. System.out.println("small x");
  8. }
  9. }
  10. }
  11.  
This will print
Expand|Select|Wrap|Line Numbers
  1. -2147483648
  2. small x
  3.  
While loop will be running continuously and if condition will be failing till x becomes -2147483648. when x reaches -2147483648, it prints small x and comes out of the loop.

Regards
Dheeraj Joshi
Apr 28 '10 #2
ramya kandasamy
9 New Member
thanks a lot
Apr 28 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1833
by: Mike Hennessy | last post by:
I'm looking for people's opinions and feedback regarding the design of the application tier, and how to best logically separate out the Data Access from the Business Object's. Per the Microsoft prescriptive architecture documents, they recommend creating a completely separate logical Data Access Tier of components. Then creating a separate tier of Business Objects that consume them. My first question is...what does this actually buy you...
0
254
by: news.microsoft.com | last post by:
I have a collection of pages and user controls in a separate project that I compile and use in a sub folder of a all my projects. This is a collection of re-usable modules that I use on every project I do. The logic in the page is to load the related "core" user control, and if the "site-specific" user control exists, load it too - most of the logic of the "page" is in the user controls... for example, I have these pages/controls in a...
3
1126
by: davidw | last post by:
I created my own WebControl, I am thinking a way to put some logics in the class to a seperated class, and it will be accessed by all instances of my WebControl, the idea is that the class doesn;t need to be created everytime, and data in it can be retrieved from database one time only. What can I achieve this? static method in class? multi-thread class? or cache? Thanks
5
1235
by: Claire | last post by:
I've explained the problem in the following code snippet. I want to share single functions for use by several data types. In this function I call different functions to fill out the original object "o" that is passed in. FileGroup is a derivative of an ArrayList object. Can I fix this problem or will I have to create a mass of overloaded functions for the whole path from where o originates right through to the database? public static...
3
14519
by: RAJESH | last post by:
I am working with c# and asp.net in developing web applications, iam using ..netframework 1.1 ,i want to know what is the need of 3-tier or 4-tier architecture in our application development.what is its part when some body is using our application.plese give links where i can find the answer.
3
2053
by: Ben Becker | last post by:
I am trying to build a custom crosstab type of grid where I take some items in a data grid and based on the content of the current item compared to the previous item, determine if a new row in a table should be created or not. In order to do this, I need to have full control over the conditional logic for how items get displayed within a repeater element which I'm not seeing as possible. How can I cursor through a data set, apply...
37
5987
by: Alan Silver | last post by:
Hello, Newbie here, so please forgive what is probably a basic question ... I see a lot of discussion about "code behind", which if I have understood correctly, means that the script code goes in a separate file from the HTML. Apart from the obvious advantage if you have a separate designer and programmer, are there any other advantages to code behind? Most of the stuff I've seen so far uses code inside, but that's probably
669
26148
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic paper written on this subject. On the Expressive Power of Programming Languages, by Matthias Felleisen, 1990. http://www.ccs.neu.edu/home/cobbe/pl-seminar-jr/notes/2003-sep-26/expressive-slides.pdf
0
1591
by: fiona | last post by:
FOR IMMEDIATE RELEASE Catalyst release low cost logic processing tool 87% of defects in software are errors in logic Yucca Valley, CA, September 2006 - Catalyst Development Corporation, publisher of SocketWrench and SocketTools, today announced the release of its first application software, a logic processing software tool. LogicGem is designed to provide a familiar, easy-to-use way to create,
23
1784
by: marora | last post by:
I keep hearing about not to use 'go_to' in your code. However, I don't know what's the reasoning behind it? Can any one here shed some light? Thanks in advance, Manish
0
9338
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9939
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9734
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8589
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7135
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6429
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5011
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5200
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2561
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.