{"id":162741,"date":"2012-12-17T12:40:03","date_gmt":"2012-12-17T08:40:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=162741"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=162741","title":{"rendered":"<span class=\"post_title\">\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u044b\u0435 Java \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 Android<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t<img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/ca1\/600\/aea\/ca1600aeab141ca05a8d99419ed01a43.png\"\/><\/p>\n<p>  \u0420\u0435\u0447\u044c \u043f\u043e\u0439\u0434\u0451\u0442 \u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0435-\u0443\u0442\u0438\u043b\u0438\u0442\u043a\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432\u0441\u044f\u043a\u043e\u043c\u0443 \u043a\u0442\u043e \u0438\u0437\u0443\u0447\u0430\u0435\u0442 Java \u0438 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u043c\u0435\u0435\u0442 \u043f\u043e\u0434 \u0440\u0443\u043a\u043e\u0439 \u041f\u041a \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043a\u043e\u0434\u0430 \u0432 \u043f\u043e\u043b\u0435\u0432\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 (\u043a\u0430\u043a-\u0442\u043e \u2014 \u0432 \u043c\u0435\u0442\u0440\u043e, \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043a\u0435, \u043a\u0430\u0444\u0435\u0448\u043a\u0435 \u0438 \u0442.\u0434.).<a name=\"habracut\"><\/a><\/p>\n<p>  \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0438\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0449\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043a\u043e\u0433\u0434\u0430 \u044f \u0433\u043e\u0442\u043e\u0432\u0438\u043b\u0441\u044f \u043a OCJP-\u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438. \u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043e\u043d\u043e\u0439, \u0440\u0435\u0448\u0438\u043b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u043b\u043e\u0434\u044b \u0441\u0432\u043e\u0438\u0445 \u0437\u0430\u0434\u0443\u043c\u043e\u043a \u043d\u0430 \u043e\u0431\u043e\u0437\u0440\u0435\u043d\u0438\u0435 \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u043c \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0430\u043c \u0445\u0430\u0431\u0440\u0430\u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430. <\/p>\n<p>  \u041d\u043e\u0443\u0442\u0431\u0443\u043a\u0430 \u0443 \u043c\u0435\u043d\u044f \u043d\u0435\u0442, \u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u0434\u0430 \u043d\u0430 \u0441\u043c\u0430\u0440\u0442\u0444\u043e\u043d\u0435, \u0441\u0438\u0434\u044f \u043d\u0430 \u043a\u0443\u0445\u043d\u0435 \u0437\u0430 \u0447\u0430\u0448\u0435\u0447\u043a\u043e\u0439 \u0447\u0430\u044f, \u0443\u0434\u043e\u0431\u043d\u043e.<\/p>\n<p>  \u0422\u0430\u043a \u0443\u0436 \u043f\u043e\u0432\u0435\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0431\u043e\u0301\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c. \u0417\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 <a href=\"https:\/\/play.google.com\/store\/apps\/details?id=com.aide.ui&amp;hl=ru\">AIDE<\/a> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c Android-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 Eclipse-\u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c, \u0443\u0432\u044b, \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u0430\u044f \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043a\u043e\u043f\u0438\u043f\u0430\u0441\u0442\u044b.<\/p>\n<p>  \u0414\u0435\u043b\u043e \u0437\u0430 \u043c\u0430\u043b\u044b\u043c \u2014 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u043e\u0442\u043e\u043a\u0438 \u0432\u0432\u043e\u0434\u0430\/\u0432\u044b\u0432\u043e\u0434\u0430 \u0432 UI \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044b:<\/p>\n<pre><code class=\"java\">    private static OutputStream mOutputStream = new OutputStream() {             @Override             public void write(int b) {                 MainActivity.getInstance().write((byte)b);             }     };      @Override     public void onCreate(Bundle savedInstanceState) {         ...         System.setOut(new PrintStream(mOutputStream));         System.setErr(new PrintStream(mOutputStream));         ...     } <\/code><\/pre>\n<p>  \u041a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435 \u0438\u0437 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 activity <code>onResume()<\/code>:<\/p>\n<pre><code class=\"java\">\t\t\t@Override \t\t\tpublic void run() { \t\t    \ttry { \t\t\t    \t\/\/ \t\t\t    \t\/\/ \u0417\u0434\u0435\u0441\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \t\t\t    \t\/\/ \t\t    \t\tProgram.main(new String[0]); \t\t    \t} catch (Throwable ex) { \/\/ \u0422\u0443\u0442 \u0436\u0435 \u043b\u043e\u0432\u0438\u043c \u0432\u0441\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \t\t    \t\tmOutput.setTextColor(Color.RED); \t\t    \t\tex.printStackTrace(); \t\t    \t} \t\t\t} <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u043c\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u2014 \u0441\u0442\u0430\u0440\u044b\u0439 \u0434\u043e\u0431\u0440\u044b\u0439 <code>args<\/code>. \u041f\u0440\u0438\u043c\u0435\u0440 \u2014 \u0437\u0430\u043f\u0443\u0441\u043a <code>BankTellerSimulation<\/code> \u043d\u0430 10 \u0441\u0435\u043a\u0443\u043d\u0434:<\/p>\n<pre><code class=\"java\">BankTellerSimulation.main(new String[] { &quot;10&quot; }); <\/code><\/pre>\n<p>  \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 (<code>SimpleThreadsTest<\/code>):<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/297\/2a6\/ec4\/2972a6ec4ad02f241626b45b47aeb7d8.png\"\/><\/p>\n<p>  <code>HorseRace<\/code> \u0438 <code>BankTellerSimulation<\/code> \u2014 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 (\u0432\u0437\u044f\u0442\u044b \u0438\u0437 \u043a\u043d\u0438\u0433\u0438 <i>Thinking in Java, 4th Ed by Bruce Eckel<\/i>).<\/p>\n<p>  \u041e\u0448\u0438\u0431\u043a\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 <code>ErrorTest<\/code>:<\/p>\n<pre><code class=\"java\">class FuuuuuuException extends RuntimeException { \tpublic FuuuuuuException(String message) { \t\tsuper(message); \t} } ... throw new FuuuuuuException(&quot;!!!TROLLFACE!!!&quot;); <\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/1ef\/82b\/709\/1ef82b709e1991d23a723dacf6e93856.png\"\/><\/p>\n<p>  \u0412\u0432\u043e\u0434<\/p>\n<p>  \u041d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a, \u0434\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0442\u044b \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439, \u0431\u044b\u043b \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0438 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u044b\u0439 \u0432\u0432\u043e\u0434. \u041f\u043e\u043a\u0430 \u0447\u0442\u043e \u043c\u043e\u0438 \u043f\u043e\u0437\u043d\u0430\u043d\u0438\u044f \u0432 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 Android \u043d\u0435 \u0432\u0435\u043b\u0438\u043a\u0438. \u041a\u043e\u0435-\u043a\u0430\u043a \u0432\u043f\u0438\u0445\u043d\u0443\u0442\u044c <code>EditText<\/code> \u0443\u0434\u0430\u043b\u043e\u0441\u044c, \u043d\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u0435\u043d \ud83d\ude42<\/p>\n<p>  \u041f\u0440\u0438\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u0435 \u0432\u0432\u043e\u0434\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 (<code>ReadingInputTest<\/code>):<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/a3a\/a28\/c46\/a3aa28c46950424fde7851cdd9f0877b.png\"\/><\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/4b0\/4c1\/aef\/4b04c1aef7dfed3d5940003f6a7bb227.png\"\/><\/p>\n<p>  Exit<\/p>\n<p>  \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0435\u0441\u0442\u044c \u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0432 \u0433\u043b\u0430\u0432\u043d\u043e\u043c \u043c\u0435\u043d\u044e. <i>Exit<\/i> \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0447\u0435\u0440\u0435\u0437 <code>System.exit(0)<\/code>.<\/p>\n<p>  \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u00ab\u043e\u0434\u043d\u043e\u0440\u0430\u0437\u043e\u0432\u0430\u044f\u00bb. \u041f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u043e\u0432 \u043d\u0435\u0442 (\u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0432\u043e\u0437\u0438\u0442\u044c\u0441\u044f \u0441 \u043e\u0447\u0438\u0441\u0442\u043a\u043e\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u043e\u043b\u0435\u0439).<\/p>\n<p>  \u0427\u0442\u043e \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/p>\n<p>  \u2022 <code>assert<\/code>&#8216;\u044b.<br \/>  \u2022 \u041a\u043b\u0430\u0441\u0441 <code>Console<\/code>.<br \/>  \u2022 \u041f\u043e\u043b\u0435 \u0432\u0432\u043e\u0434\u0430 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u0434\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0444\u043e\u043a\u0443\u0441.<\/p>\n<p>  \u0410\u0440\u0445\u0438\u0432 \u0441 Eclipse-\u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c: <a href=\"http:\/\/rapidshare.com\/files\/2724125427\/ConsoleApp.zip\"><b>ConsoleApp.zip<\/b><\/a>. <br \/>  \u041e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043f\u0430\u043a\u0435\u0442\u0435 <code>com.examples<\/code>. \u0412\u0441\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043d\u0430 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u041f\u041a (run everywhere!).    \t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/162741\/\"> http:\/\/habrahabr.ru\/post\/162741\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t<img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/ca1\/600\/aea\/ca1600aeab141ca05a8d99419ed01a43.png\"\/><\/p>\n<p>  \u0420\u0435\u0447\u044c \u043f\u043e\u0439\u0434\u0451\u0442 \u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0435-\u0443\u0442\u0438\u043b\u0438\u0442\u043a\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432\u0441\u044f\u043a\u043e\u043c\u0443 \u043a\u0442\u043e \u0438\u0437\u0443\u0447\u0430\u0435\u0442 Java \u0438 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u043c\u0435\u0435\u0442 \u043f\u043e\u0434 \u0440\u0443\u043a\u043e\u0439 \u041f\u041a \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043a\u043e\u0434\u0430 \u0432 \u043f\u043e\u043b\u0435\u0432\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 (\u043a\u0430\u043a-\u0442\u043e \u2014 \u0432 \u043c\u0435\u0442\u0440\u043e, \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043a\u0435, \u043a\u0430\u0444\u0435\u0448\u043a\u0435 \u0438 \u0442.\u0434.).<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-162741","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/162741","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=162741"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/162741\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=162741"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=162741"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=162741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}