SShortSingh.
Back to feed

Hướng dẫn vòng lặp while và do-while trong Java kèm break và continue

0
·14 views

Bài viết tiếp tục đi sâu vào các khái niệm về vòng lặp while trong Java, bao gồm vòng lặp while, do-while và cách dùng các từ khóa break và continue. Vòng lặp while thực thi khối lệnh khi điều kiện còn đúng, và điều kiện được kiểm tra trước mỗi lần lặp. Vòng lặp do-while luôn chạy khối lệnh ít nhất một lần vì điều kiện được đánh giá ở cuối vòng lặp. Từ khóa break được dùng để thoát khỏi vòng lặp hoặc switch ngay lập tức, còn continue bỏ qua lần lặp hiện tại và chuyển sang lần tiếp theo. Bài viết kèm các ví dụ minh họa mã Java cho từng trường hợp.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Two MCP tool captures diverged on the same server version due to launch settings

Two independent observers recorded different tool lists for the same mongodb-mcp-server version, with one capture showing nine extra write tools. The gap traced back to launch conditions: one sandbox started the server bare, while the other used a read-only flag and a connection string. Researchers Paraphern and HISTOR compared overlapping records covering 26 packages and found that most differences stemmed from how each capture was run. The comparison also uncovered measurement errors, including six stale snapshots that were re-captured from clean environments. The authors argue that launch arguments, network access, and authentication context should be recorded alongside tool definitions.

0
ProgrammingDEV Community ·

Python Walkthrough of LeetCode's Two Sum Problem Using a Hash Map

A DEV Community post explains LeetCode problem #1, Two Sum, an easy array task. The problem asks for the indices of two integers in an array that add up to a given target, with exactly one valid solution and no reuse of the same element. The author presents a Python solution that stores previously seen values in a dictionary and checks each new number's complement against it. The post notes that time and space complexity are left for a forthcoming video. It also promotes a DSA Decoded YouTube channel and GitHub repository, and invites readers to share alternative approaches.

0
ProgrammingDEV Community ·

Claude Code's Plan Mode: How It Works, Usage, and When to Skip It

A guide explains Claude Code's Plan Mode, a setting where the AI reads a codebase and drafts its intended changes without editing any source files until the user approves. The author argues this prevents costly mistakes from confident but misdirected edits, such as a large multi-file diff that solves the wrong problem. Plan Mode can be activated via a keyboard shortcut, the /plan slash command, a startup flag, a settings file, or the desktop and web apps. The guide also covers its permissions, the approval menu, editing plans, and situations where it is better to skip it. The author notes that Claude Code changes frequently and that the official documentation, checked in late October 2026, should be treated as authoritative.

0
ProgrammingDEV Community ·

Svelte Compiles Components to Plain JavaScript, Shipping No Framework to Browsers

Svelte differs from React, Vue, and Angular by acting as a compiler that converts components into plain JavaScript at build time rather than shipping a runtime framework. This approach yields smaller bundles and faster pages, with reactivity handled through simple variable assignment instead of hooks or setter functions. Component markup, scripts, and styles are kept together in familiar languages, and styles are automatically scoped to each component. The article notes trade-offs, including a smaller ecosystem, fewer libraries and job listings, and reactivity rules that can confuse beginners. It concludes that Svelte's simplicity suits personal projects and size-sensitive sites, and that its ideas have influenced React's compiler work.