ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzaha_5.4.0.1/evalvar.htm

76 lines
4.6 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="task" />
<meta name="DC.Title" content="Evaluate variables in Java programs" />
<meta name="abstract" content="There are two ways to evaluate a variable when a program stops running at a breakpoint or step." />
<meta name="description" content="There are two ways to evaluate a variable when a program stops running at a breakpoint or step." />
<meta name="DC.Relation" scheme="URI" content="stepping.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="evalvar" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Evaluate variables in Java programs</title>
</head>
<body id="evalvar"><a name="evalvar"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Evaluate variables in Java programs</h1>
<div><p>There are two ways to evaluate a variable when a program stops
running at a breakpoint or step.</p>
<div class="section"><ul><li>Option 1: Enter <samp class="codeph">EVAL VariableName</samp> on the debug command
line.</li>
<li>Option 2: Put the cursor on the variable name in the displayed source
code and press F11 (Display variable).</li>
</ul>
<p>Use the EVAL command for evaluating variables in a Java™ program.</p>
<div class="note"><span class="notetitle">Note:</span> You
can also change the contents of a variable by using the EVAL command. For
more information about the variations of the EVAL command, see <a href="../books/sc092712.pdf" target="_blank">WebSphere<sup>®</sup> Development Studio: ILE
C/C++ Programmer's Guide, SC09-2712</a> and online help information.</div>
<p>When
looking at variables in a Java program, note the following:</p>
<ul><li>If you evaluate a variable that is an instance of a Java class,
the first line of the display shows what kind of object it is. It also shows
an identifier for the object. Following the first display line, the contents
of each field in the object displays. If the variable is null, the first line
of the display indicates that it is null. Asterisks show the contents of each
field (of a null object).</li>
<li>If you evaluate a variable that is a Java string object, the contents of that
string displays. If the string is null, then null displays.</li>
<li>You cannot change a variable that is a string.</li>
<li>If you evaluate a variable that is an array, 'ARR' displays followed by
an identifier for that array. You can evaluate elements of the array by using
a subscript of the variable name. If the array is null, then null displays.</li>
<li>You cannot change a variable that is an array. You can change an element
of an array if it is not an array of strings or objects.</li>
<li>For variables that are arrays, you can specify arrayname.length to see
how many elements are in the array.</li>
<li>If you want to see the contents of a variable that is a field of a class,
you can specify classvariable.fieldname.</li>
<li>If you try to evaluate a variable before it has been initialized, one
of two things can happen. Either a <samp class="codeph">Variable not available to display</samp> message
is shown, or the uninitialized contents of the variable are shown, which could
be a strange value.</li>
</ul>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="stepping.htm" title="You can step through your program while debugging. You can either step over or step into other functions. Java programs and native methods can use the step function.">Step through Java programs to debug</a></div>
</div>
</div>
</body>
</html>